Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPQL query with ElementCollection throw exception
icon5.gif  JPQL query with ElementCollection throw exception [message #990129] Mon, 10 December 2012 21:43 Go to next message
Oliver Zhou is currently offline Oliver Zhou
Messages: 41
Registered: February 2012
Member
Hi,

I'm trying to use EclipseLink with jBPM. But I encountered a very strange issue which works well in Hibernate but not EclipseLink.

See this mapping:
<entity class="org.jbpm.persistence.processinstance.ProcessInstanceInfo"
              metadata-complete="true">
        <pre-update method-name="update" />
        <attributes>
            <id name="processInstanceId">
                <column name="InstanceId" />
                <generated-value strategy="AUTO"/>
            </id>
            <basic name="processId" access="FIELD" />
            <basic name="startDate" access="FIELD" >
                <temporal>TIMESTAMP</temporal>
            </basic>
            <basic name="lastReadDate" access="FIELD" >
                <temporal>TIMESTAMP</temporal>
            </basic>
            <basic name="lastModificationDate" access="FIELD" >
                <temporal>TIMESTAMP</temporal>
            </basic>
            <basic name="state" access="FIELD" />
            <basic name="processInstanceByteArray" access="FIELD" >
                <lob/>
            </basic>
            <version name="version" access="FIELD" >
                <column name="OPTLOCK" />
            </version>
            <element-collection name="eventTypes" target-class="java.lang.String" access="FIELD" >
                <collection-table name="EventTypes">
                    <join-column name="InstanceId"/>
                </collection-table> 
            </element-collection>
            <transient name="processInstance" />
            <transient name="env" />
        </attributes>
      </entity>


Then I have a named query:
select 
    processInstanceInfo.processInstanceId
from 
    ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes
where
    eventTypes = :type


EclipseLink throw the following exception:
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:229)
	... 13 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Internal problem encountered while compiling [
select 
    processInstanceInfo.processInstanceId
from 
    ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes
where
    eventTypes = :type
          ].
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildUnexpectedException(HermesParser.java:200)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:288)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:157)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138)
	at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:108)
	at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:92)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:614)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:575)
	at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2244)
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:540)
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:777)
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:722)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:213)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:542)
	... 11 more
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.jpql.TypeResolver.visit(TypeResolver.java:838)
	at org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable.accept(IdentificationVariable.java:110)
	at org.eclipse.persistence.internal.jpa.jpql.TypeResolver.resolve(TypeResolver.java:401)
	at org.eclipse.persistence.internal.jpa.jpql.JPQLQueryContext.getType(JPQLQueryContext.java:788)
	at org.eclipse.persistence.internal.jpa.jpql.ParameterTypeVisitor.getType(ParameterType.java:165)
	at org.eclipse.persistence.internal.jpa.jpql.JPQLQueryContext.getParameterType(JPQLQueryContext.java:732)
	at org.eclipse.persistence.internal.jpa.jpql.ExpressionBuilderVisitor.visit(ExpressionBuilderVisitor.java:1211)
	at org.eclipse.persistence.jpa.jpql.parser.InputParameter.accept(InputParameter.java:44)
	at org.eclipse.persistence.internal.jpa.jpql.ExpressionBuilderVisitor.visit(ExpressionBuilderVisitor.java:711)
	at org.eclipse.persistence.jpa.jpql.parser.ComparisonExpression.accept(ComparisonExpression.java:71)
	at org.eclipse.persistence.internal.jpa.jpql.ExpressionBuilderVisitor.visit(ExpressionBuilderVisitor.java:1979)
	at org.eclipse.persistence.jpa.jpql.parser.WhereClause.accept(WhereClause.java:59)
	at org.eclipse.persistence.internal.jpa.jpql.ExpressionBuilderVisitor.buildExpression(ExpressionBuilderVisitor.java:266)
	at org.eclipse.persistence.internal.jpa.jpql.JPQLQueryContext.buildExpression(JPQLQueryContext.java:314)
	at org.eclipse.persistence.internal.jpa.jpql.AbstractReadAllQueryVisitor.visit(AbstractReadAllQueryVisitor.java:237)
	at org.eclipse.persistence.jpa.jpql.parser.WhereClause.accept(WhereClause.java:59)
	at org.eclipse.persistence.internal.jpa.jpql.AbstractReadAllQueryVisitor.visitAbstractSelectStatement(AbstractReadAllQueryVisitor.java:290)
	at org.eclipse.persistence.internal.jpa.jpql.ReportQueryVisitor.visitAbstractSelectStatement(ReportQueryVisitor.java:91)
	at org.eclipse.persistence.internal.jpa.jpql.AbstractReadAllQueryVisitor.visit(AbstractReadAllQueryVisitor.java:156)
	at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:73)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:424)
	at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:73)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:404)
	at org.eclipse.persistence.jpa.jpql.parser.JPQLExpression.accept(JPQLExpression.java:136)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:274)
	... 23 more
Re: JPQL query with ElementCollection throw exception [message #990301 is a reply to message #990129] Tue, 11 December 2012 13:31 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This seems to be a bug in the new JPQL parser in 2.4. I believe it has already been fixed, so if you upgrade to the latest 2.4 patch it should fix the issue.

You could also revert to the old JPQL parser, "eclipselink.jpql.parser"="ANTLR".

The issue is most likely with,

eventTypes = :type

You could try,

eventTypes.id = :typeId


James : Wiki : Book : Blog : Twitter
Re: JPQL query with ElementCollection throw exception [message #990377 is a reply to message #990301] Wed, 12 December 2012 03:43 Go to previous message
Oliver Zhou is currently offline Oliver Zhou
Messages: 41
Registered: February 2012
Member
Thanks for your reply, unfortunently using the old parser has other issues, when version 2.4.2 got released?
Previous Topic:Objects still exists after commit
Next Topic:MOXy and JAXB Marshaller.Listener getting XMLRoot object
Goto Forum:
  


Current Time: Thu Jul 31 07:40:45 EDT 2014

Powered by FUDForum. Page generated in 0.02361 seconds