在eclipselink中选择子查询

时间:2016-03-18 06:17:07

标签: java jpa eclipselink criteria-api

根据EclipseLink documentation,它支持select子句中的子查询(即使JPA不需要它)。

当我尝试在JPA Criteria API中使用此功能时:

myCriteriaQuery
.multiselect(Arrays.asList(mySubquery, ...))
.where(...)

出现错误:

java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.querydef.SubQueryImpl cannot be cast to org.eclipse.persistence.internal.jpa.querydef.SelectionImpl

    at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.createCompoundQuery(CriteriaQueryImpl.java:511)
    at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.getDatabaseQuery(CriteriaQueryImpl.java:447)
    at org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.translate(CommonAbstractCriteriaImpl.java:198)
    at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.translate(CriteriaQueryImpl.java:691)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1551)

任何暗示为什么它不起作用?

0 个答案:

没有答案