问题
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