| Summary: | ClassCastException when aliasing select expression items | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Pascal Filion <pascal.filion> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | christopher.delahunt, eclipselink.orm-inbox, northmh, pascal.filion, peter.krogh, tom.ware | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Pascal Filion
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines I think EclipseLink parsing system doesn't parse the result variable from a JPA 2.0 JPQL query. It can't parse the following query: SELECT MOD(a.id, 2) AS m FROM Address a JOIN FETCH a.customerList ORDER BY m Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.parsing.ModNode cannot be cast to org.eclipse.persistence.internal.jpa.parsing.AliasableNode Query: JPAQuery(name="address.joinFetch" ) at org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1542) at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:589) at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:537) at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2162) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:409) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:386) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185) Note: Should be FETCH JOIN Bug is more that the JPA 2.0 specification requires any select_expression to be aliasable, but only the DotNode and AggregateNodes implement the AliasableNode. Node should implement AliasableNode (or it done away with entirely), and isAliasableNode return false on nodes that cannot be select_expressions (if there are any). Another way to reproduce this issue, using the JPQL 'FUNC' keyword:
SELECT FUNC('ISNULL', MAX(e.TableID), 0) AS maxId FROM EntityTable e;
The above causes:
java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.parsing.FuncNode cannot be cast to org.eclipse.persistence.internal.jpa.parsing.AliasableNode
Eliminating the 'AS maxId' alias specifier in the query makes the error go away:
SELECT FUNC('ISNULL', MAX(e.TableID), 0) FROM EntityTable e;
bug scrub Created attachment 199925 [details]
proposed fix
Fix checked in to 2.3.1 and trunk Fix makes all NOdes that are selectable implement AliasableNode Reviewed by Guy Pelletier Tested with JPA LRG Added test to JUNitJPQLComplexTestSuite The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |