我有一个名为 Profile 的类及其 JPA 存储库 ProfileRepo我正在尝试使用 findBy 方法来查找使用名字或中间名或姓氏以及包含子句的名称.
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
}
我在 JPA 存储库中使用以下查询,但它不接受该方法
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);
请帮忙.
试试这个:
List<Profile> findByFirstNameIgnoreCaseContainingOrLastNameIgnoreCaseContainingOrMidNameIgnoreCaseContaining(String firstName, String lastName, String midName);
或者这个:
@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);
这篇关于对多个字段使用 findBy 并对所有字段使用包含子句的 Spring Data JPA 方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)