Reputation: 14717
Based on the Spring Data documentation, it is easy to do conditions such as A Or B. Example:
List<Person> findByLastnameOrFirstname(String lastname, String firstname);
I wouild like to know how to write a query with conditions A And (B Or C). Something like the following:
List<Person> findByEmailAddressAnd(LastnameOrFirstname)(String emailAddress, String lastname, String firstname);
Thanks and regards.
Upvotes: 0
Views: 291
Reputation: 20135
You can use the @Query
annotation.
@Query("SELECT p FROM Person p WHERE p.emailAddress=:emailAddress AND (p.lastName=:lastName OR p.firstName=:firstName)")
List<Person> findByEmailAddressAnd(LastnameOrFirstname)(String emailAddress, String lastname, String firstname);
Upvotes: 2