강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

ryu님의 프로필 이미지
ryu

작성한 질문수

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

상품 등록

Setter 제거 관련 질문

작성

·

349

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());

답변 1

0

김영한님의 프로필 이미지
김영한
지식공유자

안녕하세요. 박상훈님

다음에 답변 남겨드렸습니다.

https://www.inflearn.com/questions/294684

감사합니다.

ryu님의 프로필 이미지
ryu

작성한 질문수

질문하기