본문 바로가기

JPA6

[Spring/Error] No serializer found for class 오류 : No serializer found for class ... and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) Serialize : Object to JSON Deserialize : JSON to Object the default configuration of an ObjectMapper instance is to only access properties that are public fields or have public getters/setters. Jackson 라이브러리의 ObjectMapper는 Serialize 할.. 2023. 10. 10.
[Spring/Error] ids for this class must be manually assigned before calling save(): Spring, JPA 사용 시 ids for this class must be manually assigned before calling save(): 에러 발생 save() 함수 호출 전 id 값이 설정되어 있어야 함을 의미. 해결방법 DB에서 id 값을 Auto Increment 로 했을 때 entity 에서도 @GeneratedValue 어노테이션이 설정되어 있어야 한다. 참고 : https://hangjastar.tistory.com/241 2023. 2. 1.
[Spring/Error] Not a managed type: class 명 error JPA 사용 시 Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: 에러 발생 해결방법 해당 class에 @Entity 어노테이션 추가 참고 : https://wakestand.tistory.com/742 2023. 1. 25.
[Spring] JPA Querydsl Unsupported expression Querydsl Unsupported expression 오류 해결 방법 .as()를 통해 alias 사용하기 qHolding.goods_cnt.sum().as("sumGoodsCnt"), Expressions.stringTemplate("group_concat({0})", qHolding.user.user_id).as("userIds") GoodsHoldingDto.java public class GoodsHoldingDto { private Long goodsId; private String goodsNm; private Integer sumGoodsCnt; private String userIds; @QueryProjection public GoodsHoldingDto(Long goodsId, St.. 2022. 10. 9.
[Spring] inflearn 스프링 입문 - 스프링 DB 접근 기술 6 스프링 데이터 JPA 인터페이스만으로 개발 완료. 반복적으로 개발해온 CRUD 기능도 스프링 데이터 JPA가 제공. 코드 적을 게 없음. 그냥 쓰면 됨. 스프링부트 + JPA + 스프링 데이터 JPA 프레임워크. 관계형 데이터베이스 사용 시 스프링 데이터 JPA 필수 스프링 데이터 JPA는 JPA를 편리하게 사용하도록 도와주는 라이브러리. JPA 먼저 학습. 실제 운영시 문제들 해결할 수 없음 src/main/java/hello/hellospring/repository/SpringdataJpaMemberRepository.java SpringdataJpaMemberRepository 인터페이스 생성 인터페이스가 인터페이스를 받을 때는 extends JpaRepository T : Member ID: en.. 2022. 9. 15.
[Spring] inflearn 스프링 입문 - 스프링 DB 접근 기술 5 JPA JDBC -> JdbcTemplate : 반복적인 코드 줄음. but sql 쿼리는 직접 작성해야 함. JPA 기술을 사용하면 sql 쿼리도 JPA가 자동으로 처리. 개발 생산성 높임. 객체를 JPA에 넣으면 JPA가 중간에서 DB에 sql을 날리고 데이터를 db에서 가져오는 것 처리. sql, 데이터 중심 설계에서 객체 중심 설계로 전환. build.gradle dependency 추가. jpa관련 라이브러리 추가. implementation 'org.springframework.boot:spring-boot-starter-data-jpa' resources/application.properties JPA관련 설정 추가 jpa가 날리는 sql 볼 수 있음 spring.jpa.show-sql=tr.. 2022. 9. 15.