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
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?