Well keep it simple I want to build a query to make it equivalent to:
select * from user where (name like ? or detail like ?) and age = ?
What I have tried so far:
Page<Post> findByNameOrDetailContainingAndAgeEquals(String query, int age, Pageable pageable);
Page<Post> findByNameContainingOrDetailContainingAndAgeEquals(String query, String query, int age, Pageable pageable);
All of these approaches failed. It seems that Spring split the query very wrong.
I have checked all the examples in https://github.com/spring-projects/spring-data-jpa/blob/main/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java but all of those examples are pretty simple (most queries even with just one simple condition).
All I have read this answer How to combine multiple And and Or through method name and I agree with it. BUT, I don't think my scenario is complicated as the OP's, as you can see. Just "AND" and "OR" query condition combined which is quite easy in a SQL way but I just want make it by a JPA way.