Optimize Spring-Data JPA queries

后端 未结 2 1121
花落未央
花落未央 2020-12-28 18:22

I am looking for possible optimizations for framework-generated queries. As far as I understand, the process is the following:

  • you could declare your domain

2条回答
  •  醉酒成梦
    2020-12-28 19:16

    One solution is to use DTO's:

    @Query("select new FilteredOrder(o.name, o.size, o.cost) from Order o where o.id = ?1")
    Page findFilteredOrderById(Pageable pageable, String id);
    

    If you want to have entities for some reports generation maybe you should think about using nosql datastore?

提交回复
热议问题