I have a class called Profile and its JPA repository ProfileRepo I'm trying to use findBy method to find names using first name or middle name or last name and also using containing clause.
public class Profile{
private String firstName;
private String middleName;
private String lastName;
//getters and setters
}
Am using the following query in the JPA repository but it is not accepting the method
List<Profile> findByLastNameContainingOrFirstNameContainingOrMiddleNameContainingAllIgnoreCase(String firstName,
String lastName,String midName);
Kindly help out.
Try this:
List<Profile> findByFirstNameIgnoreCaseContainingOrLastNameIgnoreCaseContainingOrMidNameIgnoreCaseContaining(String firstName, String lastName, String midName);
or this:
@Query("select p from Profile p where upper(p.firstName) like concat('%', upper(?1), '%') or upper(p.lastName) like concat('%', upper(?2), '%') or upper(p.midName) like concat('%', upper(?3), '%')")
List<Profile> getByNames(String firstName, String lastName, String midName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With