본문 바로가기
반응형

JPA3

[ Spring ] TransientPropertyValueException 에러 해결 방법 💥 application run 시 발생한 에러 메시지Error creating bean with name 'initDb': Invocation of init method failedCaused by: java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.OrderItem.item -> jpabook.jpashop.domain.item.ItemCaused by: org.hibernate.TransientP.. 2024. 5. 20.
[Spring] 검색 요청 JPQL에서 QueryDSL로 변경하기 프로젝트를 진행 중 기존 검색 요청을 JQPL에서 QueryDSL로 변경하기로 하였다. 변경 이유에 대해서 간략하게 설명드리겠습니다. 아래에 변경 전 코드를 추가해 두었지만, JPA(JPQL)에서는 컴파일 시 N.P를 막지 못한다는 단점이 존재합니다. 그래서 필드의 Null처리를 위해서 서비스 코드의 코드 양 자체가 많아 진다는 단점이 존재합니다. 만약에 검색 조건이 2개에서 1개가 추가된다고 가정해 보면 필요한 JPQL의 최대 개수는 7개가 됩니다. 그렇게 되면 필요한 쿼리 메서드만 7개가 되어버리고 서비스 코드에 절대적으로 7줄이 추가될 수밖에 없습니다. QueyrDSL을 사용하게 되면 기존의 SOLID를 위배하지 않는 선에서 서비스 코드의 코드 양 자체를 줄일 수 있게 됩니다. 변경 전 코드 Sea.. 2024. 4. 15.
[ QueryDSL ][ Spring ] Unable to load class 'javax.persistence.Entity' 에러 해결 방법 Spring 3.x 이상의 버전 사용 시 QueryDSL을 implementation 하면 발생하는 에러입니다. Unable to load class 'javax.persistence.Entity'.This is an unexpected error. Please file a bug containing the idea.log file. import com.example.demo.domain.QEntity  에러 발생 이유 Spring의 build.gradle에 QueryDSL을 implementation한 방식이 Spring 3.x 버전이 아니라Spring 2.X 버전일 경우 나타나는 에러입니다. Spring 2.x 버전에서 Spring 3.x 버전으로 올라오면서 Java17버전을 사용하게 되었습니다.JA.. 2024. 3. 4.
반응형