Community
Participate
Working Groups
Build Identifier: 2.1.2.v20101104-r8475 org.eclipse.persistence.internal.jpa.parsing.Node isAliasableNode() : returns true by default but should return false Reproducible: Always Steps to Reproduce: Try to parse "SELECT e.salary / 1000D n From Employee e" and a Class cast exception is thrown: Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.parsing.DivideNode cannot be cast to org.eclipse.persistence.internal.jpa.parsing.AliasableNode at org.eclipse.persistence.internal.jpa.parsing.SelectNode.applyToQuery(SelectNode.java:171) at org.eclipse.persistence.internal.jpa.parsing.ParseTree.applyQueryNodeToQuery(ParseTree.java:334) at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateReadQueryInternal(JPQLParseTree.java:113) at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateQuery(JPQLParseTree.java:84) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:211) at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:106) at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:90) at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:509)
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