jpashop : get data api v3 (fetch join)
This commit is contained in:
@@ -11,9 +11,9 @@ public class JpashopApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(JpashopApplication.class, args);
|
||||
}
|
||||
@Bean
|
||||
Hibernate5Module hibernate5Module() {
|
||||
return new Hibernate5Module();
|
||||
// .configure(Hibernate5Module.Feature.FORCE_LAZY_LOADING, true);
|
||||
}
|
||||
// @Bean
|
||||
// Hibernate5Module hibernate5Module() {
|
||||
// return new Hibernate5Module();
|
||||
//// .configure(Hibernate5Module.Feature.FORCE_LAZY_LOADING, true);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -46,4 +46,12 @@ public class OrderSimpleApiController {
|
||||
.map(SimpleOrderDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("/api/v3/simple-orders")
|
||||
public List<SimpleOrderDto> ordersV3() {
|
||||
List<Order> orders = orderRepository.findAllWithMemberDelivery();
|
||||
return orders.stream()
|
||||
.map(SimpleOrderDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,12 @@ public class OrderRepository {
|
||||
.setMaxResults(1000) // 최대 1000건건
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
public List<Order> findAllWithMemberDelivery() {
|
||||
return em.createQuery(
|
||||
"select o from Order o" +
|
||||
" join fetch o.member m" +
|
||||
" join fetch o.delivery", Order.class)
|
||||
.getResultList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user