JPA findby列名包含多个列,条件为“ And”和“ OR”

时间:2019-05-07 14:27:35

标签: jpa

我遇到的情况是,我需要搜索包含我的搜索文本的数据,其中othercolumn等于列ID, 基本上,搜索应该针对名,姓,电子邮件,联系人编号,其中id = someinteger

我尝试使用以下查询“ like”运算符

@Query("select p from Patient p where p.subscriber.id=?1 and (upper(p.firstname) like %?2% OR upper(p.lastname) like %?3% OR p.cellPhone like %?4% OR p.id = ?5 OR upper(p.email) like %?6%)")
    List<Patient> findPatientByText(long subid, String name, String lastname, String num, int id, String email);

以上查询不适用于不区分大小写的内容。 经过一些搜索后,我发现containsIgnorecase可以提供帮助,但这是在整个表中搜索,但是我只需要在给定id的整数位置进行搜索。 我尝试的存储库方法是。

List<modelclas> findBySubscriberIdAndFirstnameContainingIgnoreCaseOrLastnameContainingIgnoreCaseOrEmailContainingIgnoreCase(long id,
            String searchText, String searchText2, String searchText3); 

我只需要获得搜索结果,只要user.id = id,并且“ OR”应应用于其他列

0 个答案:

没有答案