Java – spring data dynamic query

I am using spring data to set up a dynamic query. Basically, I have an array with a series of features. I need to combine the query according to these features, almost like "where feature = A and feature = B and feature = C", but the feature quantity may be different

I noticed that I can use @ query annotations, but can I make @ query pagable results?

Is there any way to finish this?

Page<Recipe> findDistinctByNameContainingAndOrganizationAndcharacteristicsInOrIngredientsContainingAndOrganizationAndcharacteristicsInOrDescriptionContainingAndOrganizationAndcharacteristicsInAllIgnoreCase(
        String name,Organization organization1,List<Characteristic> characteristic1,String ingredients,Organization organization2,List<Characteristic> characteristic2,String description,Organization organization3,List<Characteristic> characteristic3,Pageable pageable);

Solution

Yes@ Query supports pageable Yes, there is another way to do this

You can view queries built using criteria, allowing you to dynamically add criteria and / or criteria I actually use querydsl to promote my development

In this article, you can find a good explanation: http://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/

Assuming that it may look more complex at first, using this function will make your code more consistent and increase complexity

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>