본문 바로가기
반응형

Boot14

[ 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.
[MySQL] Error Code:3730. Cannot drop table 해결 방법 💥 MySQL drop table 시 발생한 에러 메시지 Error Code:3730. Cannot drop table '테이블명'... ❓에러 발생 이유 테이블에 참조하고 있는 참조되어 있는 테이블이(FK) 존재하여 테이블이 삭제되지 않는 상황입니다. ✅ 해결 방법 ✔️ 해결 방법 참조되어 있는 테이블 삭제 삭제하려는 테이블의 FK가 참조되어 있는 테이블을 삭제합니다. drop table '테이블명' FK 설정 삭제 SET foreign_key_checks = 0; FK 설정 비활성화를 진행 후 삭제를 원하시는 테이블을 삭제 완료 하셨다면, FK 설정을 다시 활성화 해주셔야 합니다. SET foreign_key_checks = 1; 2024. 4. 15.
[ QueryDSL ] Parameter 0 of constructor in ArticleRepositoryCustomImpl required a bean of type 'java.lang.Class' that could not be found. 에러 해결 방법 💥 Application run 시 발생한 에러 메시지Description:Parameter 0 of constructor in com.example.demo.repository.querydsl.ArticleRepositoryCustomImpl required a bean of type 'java.lang.Class' that could not be found.Action:Consider defining a bean of type 'java.lang.Class' in your configuration. ❓에러 발생 이유Consider defining a bean of type 'java.lang.Class' in your configuration.라는 문구는 보통 Spring이 실행되면서 java 파일.. 2024. 4. 10.
반응형