问题
I want to use projections in order to return less elements for the same queries.
Page<Network> findByIdIn(List<Long> ids);
Page<NetworkSimple> findByIdIn(List<Long> ids);
Since the queries are created using the name of the method, what options do I have to do the same query but with different name ?
回答1:
Spring Data query via method is constructed by convention and you can't change the name and yet expecting a same behavior.
You can try to use @Query annotations which doesn't depend on the method name, or possibly implementing custom DAO using JPAQuery plus FactoryExpression which has the same effect as projections.
来源:https://stackoverflow.com/questions/36548298/same-query-method-and-parameters-with-different-return-in-spring-data