백기선 님이 YouTube에 올린 영상 중에 @RequiredArgsConstructor 관한 것이 있다.
@RequiredArgsConstructor// final로 선언된 멤버 변수를 자동으로 생성합니다.
@Service// 서비스임을 선언합니다.
public class ProductService {
private final ProductRepository productRepository;
@Transactional // 메소드 동작이 SQL 쿼리문임을 선언합니다.
public Long update(Long id, ProductMypriceRequestDto requestDto){
Product product = productRepository.findById(id).orElseThrow(
()->new NullPointerException("해당 아이디가 존재하지 않습니다")
);
product .update(requestDto);
return id;
}
}
'Programming > Spring' 카테고리의 다른 글
@DateTimeFormat(pattern = "yyyy-MM-dd") (0) | 2021.09.18 |
---|---|
어노테이션 (0) | 2021.09.17 |
JPA Auditing으로 생성일/수정일 자동화하기 (0) | 2021.02.05 |
[JPA] find date between 날짜 사이 찾기 (0) | 2021.02.05 |
[JPA] Entity와 Repository의 관계, Repository의 기본 메서드/추가 메서드 (0) | 2021.02.05 |