JPA and ( or )

Posted nm666

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JPA and ( or )相关的知识,希望对你有一定的参考价值。

Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(Calendar.YEAR, Integer.valueOf(reportYear));
Date yearFirst = calendar.getTime();
Calendar calendar0 = Calendar.getInstance();
calendar0.clear();
calendar0.set(Calendar.YEAR, Integer.valueOf(reportYear)+1);
Date yearEnd = calendar0.getTime();

//重点
predicates.add(
        cb.or(
                cb.between(root.get("flowEndTime"),yearFirst,yearEnd),
                cb.greaterThanOrEqualTo(root.join("closeReport", JoinType.LEFT).get("flowEndTime"),yearFirst)
         )
 );
                                 

where project0_.flow_status = ?
and (project0_.flow_end_time between ? and ? or projectclo3_.flow_end_time >= ?)

以上是关于JPA and ( or )的主要内容,如果未能解决你的问题,请参考以下文章

Spring Data JPA学习笔记

带有'like'和'or'的Spring JPA @Query where子句

JPA#复杂查询#引子

Java : JPA相关以及常用注解

Spring Data JPA 简单查询

带有 IN 语句的 JPA 本机查询