条件查询eclipse链接子查询,其中比较不起作用(lessthanorequalto,greaterthanorequalto…)

gc0ot86w  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(165)

我有这个:

//subquery whit max
Subquery<Date> subqueryMaxDateCourses = query.subquery(Date.class);
Root<ExpedienteCurso> subrootMaxDateCourses = subqueryMaxDateCourses.from(Course.class);
subqueryMaxDateCourses.select(builder.greatest(subrootMaxDateCourses.get("dateField")));

//this code works as I expect (select * from ... where :date = (select max(date) from ...))
predicates.add(builder.equal(subqueryMaxDateCourses,filter.getDate()));
//this code does not work
predicates.add(builder.lessThanOrEqualTo(subqueryMaxDateCourses,filter.getDate()));

第二行抛出此错误:

java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.querydef.SubQueryImpl cannot be cast to org.eclipse.persistence.internal.jpa.querydef.ExpressionImpl
javax.faces.FacesException: #{expedienteSubvencionList.buscar}: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.querydef.SubQueryImpl cannot be cast to org.eclipse.persistence.internal.jpa.querydef.ExpressionImpl

我正在使用springboot wiht:org.eclipse.persistence.jpa2.7.4
我不明白为什么第二条线不行。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题