Subqueries in select in eclipselink

放肆的年华 提交于 2021-01-28 04:38:47

问题


According to EclipseLink documentation it supports subqueries in the select clause (even if JPA doesn't require it).

When I try to use this feature in JPA Criteria API:

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

there is an error:

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)

Any hint why it doesn't work?

来源:https://stackoverflow.com/questions/36077435/subqueries-in-select-in-eclipselink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!