我有这个:
//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
我不明白为什么第二条线不行。
暂无答案!
目前还没有任何答案,快来回答吧!