list형 json custom converter 사용 import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import javax.persistence.AttributeConverter; import java.io.IOException; import java.util.List; public class StringListConverter implements AttributeConverter { private static final ObjectMapper..
entity에 enum list를 정의하고 싶을 때 사용! 1. enum 생성 public enum IndicatorReportType { ROE, TOTAL_REVENUE, TOTAL_EQUITY } 2. Converter를 만들고 public class ReportListConverter implements AttributeConverter { private static final ObjectMapper mapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false); ..
@Entity @Table(name = "tb_item") @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Item extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; @Column(columnDefinition = "VARCHAR", length = 10) private String str; }
querydsl 사용할 경우 public Page findItemBy(SearchItemClause clause, Pageable pageable) { QueryResults results = jpaQueryFactory.select(QItem.item) .from(item) .where(clause.whereClause()) .distinct() .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .fetchResults(); results.getResults().stream().map(Item::getSubItem).forEach(Hibernate::initialize); return new PageImpl(results.getResults()..
자바 객체와 데이터베이스 테이블 간의 매핑을 처리하는 ORM(Object Relational Mapping) 기술의 표준. 장단점 장점 개ㅐ발이 편리 - 기본적인 CRUD 작성 하지 않아도 됨. 데이터베이스에 독립적인 개발이 가능하다 - 데이터베이스에 종속적이지 않다. 사용 DB가 바뀌면 jpa가 해당 db에 맞는 쿼리 생성해 준다. 유지 보수가 쉽다. 단점 학습곡선이 크다 - 배워야 할게 많고, 튜닝 할 때도 어려움이 있음. 특정 DB에 종속적인 기능을 사용하지 못한다. 객체지향 설계가 필요 스프링 데이터 JPA JPA를 스프링에서 쉽게 사용할 수 있도록 해주는 라이브러리. Repository라는 인터페이스를 상속 받아 정해진 규칙에 맞게 메서드를 작성하면 개발자가 작성해야 할 코드 완성. JPA 구현..
- Total
- Today
- Yesterday