I would like to create a Spring Data JPA query that uses a default criterion and a dynamic predicate.
For example using Customer entity:
findByFirstnameIn(List<String> names, Predicate predicate);
I can't find similar examples in the Spring Data JPA documentation
Another solution would be to use do
findAll(predicate.and(customer.firstname.in(names)))
but I would like to avoid this additional line of code.
Your second approach is the correct way to do it. There is a similar feature request you might want to keep an eye on https://github.com/spring-projects/spring-data-jpa/issues/1524