인프런 커뮤니티 질문&답변
Setter 제거 관련 질문
작성
·
351
0
Setter 를 어떻게 지울까 하다가 이렇게 생성자로 했는데,
이렇게 해도 올바른 방법일까요 ? 아니면 다른 방법이 훨씬 유효할까요..?
생성 메서드를 해보려 했는데 ,
GetMapping 에서 빈 폼을 가져올 때 stockQuantity 와
price 에서 null 땜에 바인딩 미스매치 에러가 뜨더라구요
매개변수에 @Nullable 을 줬는데도 해결이 안되서요
public Book(String author, String isbn, String name, int price, int stockQuantity) {
super(name,price,stockQuantity);
this.author = author;
this.isbn = isbn;
}
public Item(String name, int price, int stockQuantity) {
this.name = name;
this.price = price;
this.stockQuantity = stockQuantity;
}
Book book = new Book(form.getAuthor(),form.getIsbn(),form.getName(),form.getPrice(),form.getStockQuantity());
퀴즈
61%나 틀려요. 한번 도전해보세요!
회원 가입 시 화면 입력 데이터를 엔티티 객체 대신 별도의 Form 객체로 받는 주된 이유는 무엇일까요?
데이터베이스 성능을 최적화하기 위해서
화면 종속적인 데이터나 유효성 검증 로직을 분리하기 위해서
JPA 영속성 컨텍스트와 직접적인 관계를 맺기 위해서
코드의 자동 생성 기능을 활용하기 위해서





