일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- JPA
- @MappedSuperclass
- 친절한 SQL 튜닝
- DTO
- index
- 값 타입
- 오라클
- TCP/IP
- 자바의 정석
- 정렬
- 스프링
- 그룹함수
- SQL
- Spring
- 스프링 데이터 JPA
- 서브쿼리
- INDEX SCAN
- 데이터베이스
- 페치조인
- 성능최적화
- JPQL
- 스프링 컨테이너
- Spring data JPA
- 페이징
- SQL 튜닝
- querydsl
- 엔티티
- 데이터모델링
- fetch join
- 컬렉션 조회 최적화
- Today
- Total
목록DTO (4)
nu_s
V4. JPA에서 DTO 직접 조회하기 앞에서는 엔티티를 DTO로 변환해서 컬렉션으로 반환했다. 이번에는 DTO를 그대로 반환해서 JPA가 DTO를 직접 조회하게 만들어 보겠다. @RestController @RequiredArgsConstructor public class OrderApiController { private final OrderQueryRepository orderQueryRepository; @GetMapping("/api/v4/orders") public List orderV4() { return orderQueryRepository.findOrderQueryDtos(); } } jpabook.jpashop.repository.order.query.OrderQueryDto @Data..
컬렉션 조회 최적화 이전에는 XXXToOne 관계를 다뤘다면 이번엔 컬렉션인 일대다 관계 (OneToMany)를 조회하고 최적화 해보자 V1. 엔티티 직접 노출 @RestController @RequiredArgsConstructor public class OrderApiController { private final OrderRepository orderRepository; @GetMapping("/api/v1/orders") public List orderV1() { List all = orderRepository.findAllByString(new OrderSearch()); for (Order order : all) { order.getMember().getName(); order.getDeliv..
V4. JPA에서 DTO로 바로 조회하기 쿼리 한 번 호출 select 절에서 원하는 데이터만 선택해서 조회 @RestController @RequiredArgsConstructor public class OrderSimpleApiController { private final OrderSimpleQueryRepository orderSimpleQueryRepository; @GetMapping("/api/v4/simple-orders") public List ordersV4() { return orderSimpleQueryRepository.findOrderDtos(); } } OrderSimpleQueryRepository (조회 전용 리포지토리) @Repository @RequiredArgsCons..

V2. 엔티티를 DTO로 변환 @RestController @RequiredArgsConstructor public class OrderSimpleApiController { private final OrderRepository orderRepository; @GetMapping("/api/v2/simple-orders") public List ordersV2() { List orders = orderRepository.findAllByString(new OrderSearch()); List result = orders.stream() .map(o -> new SimpleOrderDto(o)) // Order를 SimpleOrderDto로 변환 .collect(Collectors.toList()); re..