You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
5️⃣ JPA 적용1 - 개발
itemNameitem_name,따라서 위 예제의@Column(name = "item_name")를생략해도 된다.6️⃣ JPA 적용2 - 리포지토리 분석
➡️save() - 저장
➡️update() - 수정
@Commit을 붙이면 확인할 수 있다.➡️ findById() - 단건 조회
JPA에서 엔티티 객체를 PK를 기준으로 조회할 때는 find()를 사용하고 조회 타입과, PK값을 주면 된다.
JPA가 다음과 같이 조회 SQL을 만들고 실행하고 결과를 객체로 바로 변환해준다.
JPA가 만들어서 실행한 SQL
➡️ findAll - 목록 조회
JPQL
from다음에Item엔티티 객체 이름이 들어간다. 엔티티 객체와 속성의 대소문자는 구분해야 한다.실행된 JPQL
7️⃣ JPA 적용3 - 예외 변환
✅@repository
@repository 가 붙은 클래스는 컴포넌트 스캔의 대상이 된다.
@repository 가 붙은 클래스는 예외 변환 AOP의 적용 대상이 된다.
예외 변환 후
@Repository애노테이션만 있으면 스프링이 예외 변환을 처리하는 AOP를 만들어준다.All reactions