Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] join fetch fails with "DotNode cannot be cast to VariableNode"

Hi,

I have these mappings:

In TestClassA:

    @OneToOne(fetch = FetchType.LAZY)
    public TestClassB getObjectBLocalFk() {
        return objectBLocalFk;
    }



In TestClassB:



    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="objectALocal_Fk")
    public TestClassA getObjectALocalFk() {
        return objectALocalFk;
    }

In this example both relationships are one-to-one but with other types it also happens.



I have tested the suggested workaround and it worked.



Thanks,

    Constantino.




________________________________

Message: 4
Date: Mon, 06 Dec 2010 08:57:23 -0500
From: Tom Ware <tom.ware@xxxxxxxxxx>
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Subject: Re: [eclipselink-users] join fetch fails with "DotNode cannot
        be cast to VariableNode"
Message-ID: <4CFCEBC3.20002@xxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Constantino,

   What type of mappings are used for for x.objectBLocalFk and for
objectBLocalFk.objectALocalFk?

   You may be able to workaround this with our fetch query hint.  Something like:

query.setHint(QueryHints.FETCH, "x.objectBLocalFk.objectALocalFk");

-Tom

Cronemberger, Constantino wrote:
> Hi,
>
> When I try to execute this query:
>
> select x from TestClassA x join fetch x.objectBLocalFk join fetch x.objectBLocalFk.objectALocalFk
>
> I get the following exception:
>
> java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.parsing.DotNode cannot be cast to org.eclipse.persistence.internal.jpa.parsing.VariableNode
>     at org.eclipse.persistence.internal.jpa.parsing.FetchJoinNode.validate(FetchJoinNode.java:73)
>     at org.eclipse.persistence.internal.jpa.parsing.FromNode.validate(FromNode.java:69)
>     at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:199)
>     at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:183)
>     at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:173)
>     at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateReadQueryInternal(JPQLParseTree.java:110)
>     at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateQuery(JPQLParseTree.java:84)
>     at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:216)
>     at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:187)
>     at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:139)
>     at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:123)
>     at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1374)
>
> Is there a workaround for this?
>
> Thanks,
>    Constantino
>
> ________________________________
> From: Cronemberger, Constantino
> Sent: 01 December 2010 16:51
> To: eclipselink-users@xxxxxxxxxxx
> Subject: Re: [eclipselink-users] inactiveUnitOfWork with OptimisticLockException
>
> Hi,
>
> I am using JPA.
>
> When I throw a runtime exception manually I don't see this problem.
>
> I am using Spring to control the transaction, so it is doing the commit.
>
> Here is my persistence.xml:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>                                  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
>     <persistence-unit name="test" transaction-type="JTA">
>     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
>         <!-- For some reason EclipseLink does not recognize this datassource.
>              It was necessary to add a property with name
>              "javax.persistence.jtaDataSource" at the end of this file.
>         <jta-data-source>java:comp/env/jdbc/testDs</jta-data-source>
>            -->
>         <class>com.test.TestClassA</class>
>         <class>com.test.TestClassB</class>
>         <validation-mode>CALLBACK</validation-mode>
>         <properties>
>             <property name="eclipselink.target-server" value="Weblogic"/>
>             <property name="eclipselink.weaving" value="static"/>
>             <property name="eclipselink.weaving.lazy" value="true"/>
>             <property name="eclipselink.jdbc.batch-writing" value="JDBC" />
>             <property name="eclipselink.persistence-context.flush-mode" value="COMMIT" />
>             <property name="eclipselink.cache.size.default" value="1000" />
>             <property name="eclipselink.cache.coordination.protocol" value="rmi" />
>             <property name="javax.persistence.jtaDataSource"
>                       value="java:comp/env/jdbc/testDs"/>
>             <property name="javax.persistence.query.timeout" value="120"/>
>         </properties>
>     </persistence-unit>
> </persistence>
> The two stack traces I get are:
>
> from weblogic:
>
> ####<01-Dec-2010 16:44:33 o'clock BRST> <Warning> <JTA> <SPMADLT0374> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1291229073404> <BEA-110401> <Ignoring error in afterCompletion. Object=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16<mailto:Object=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16>, Exception=Exception [EclipseLink-23011] (Eclipse Persistence Services - 2.2.0.v20101117-r8503): org.eclipse.persistence.exceptions.TransactionException
> Exception Description: Error trying to format exception message: UnitOfWork [{0}] was rendered inactive before associated externally managed transaction was complete.  The arguments are: [Exception [EclipseLink-4022] (Eclipse Persistence Services - 2.2.0.v20101117-r8503): org.eclipse.persistence.exceptions.DatabaseException
> Exception Description: Accessor or its connection has been set to null.  This can occur if the ClientSession or UnitOfWork was released in a seperate thread, for instance if a Timeout occurred.]
> Exception [EclipseLink-23011] (Eclipse Persistence Services - 2.2.0.v20101117-r8503): org.eclipse.persistence.exceptions.TransactionException
> Exception Description: Error trying to format exception message: UnitOfWork [{0}] was rendered inactive before associated externally managed transaction was complete.  The arguments are: [Exception [EclipseLink-4022] (Eclipse Persistence Services - 2.2.0.v20101117-r8503): org.eclipse.persistence.exceptions.DatabaseException
> Exception Description: Accessor or its connection has been set to null.  This can occur if the ClientSession or UnitOfWork was released in a seperate thread, for instance if a Timeout occurred.]
>  at org.eclipse.persistence.exceptions.TransactionException.inactiveUnitOfWork(TransactionException.java:118)
>  at org.eclipse.persistence.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:203)
>  at org.eclipse.persistence.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:79)
>  at weblogic.transaction.internal.ServerSCInfo.doAfterCompletion(ServerSCInfo.java:1023)
>  at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:999)
>  at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:2996)
>  at weblogic.transaction.internal.ServerTransactionImpl.afterRolledBackStateHousekeeping(ServerTransactionImpl.java:2877)
>  at weblogic.transaction.internal.ServerTransactionImpl.setRolledBack(ServerTransactionImpl.java:2853)
>  at weblogic.transaction.internal.ServerTransactionImpl.globalRetryRollback(ServerTransactionImpl.java:3093)
>  at weblogic.transaction.internal.ServerTransactionImpl.globalRollback(ServerTransactionImpl.java:2843)
>  at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:328)
>  at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:224)
>  at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:292)
>  at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1009)
>  at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
>  at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
>  at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:375)
>  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
>  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>  at $Proxy193.updateType(Unknown Source)
> from application:
>
> org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16<mailto:sync=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16>
> Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read
>  at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1012)
>  at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
>  at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
>  at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:375)
>  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
>  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>  at $Proxy193.updateType(Unknown Source)
> ...
> Caused by: weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16<mailto:sync=org.eclipse.persistence.transaction.JTASynchronizationListener@99eb16>
> Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read
>  at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1871)
>  at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:330)
>  at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:224)
>  at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:292)
>  at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1009)
>  ... 61 more
> Caused by: Exception [EclipseLink-5011] (Eclipse Persistence Services - 2.2.0.v20101117-r8503): org.eclipse.persistence.exceptions.OptimisticLockException
> Exception Description: One or more objects cannot be updated because it has changed or been deleted since it was last read
>  at org.eclipse.persistence.exceptions.OptimisticLockException.batchStatementExecutionFailure(OptimisticLockException.java:79)
>  at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:143)
>  at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.writesCompleted(DatabaseAccessor.java:1632)
>  at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.commitTransaction(DatabaseAccessor.java:399)
>  at org.eclipse.persistence.internal.sessions.AbstractSession.basicCommitTransaction(AbstractSession.java:506)
>  at org.eclipse.persistence.sessions.server.ClientSession.basicCommitTransaction(ClientSession.java:155)
>  at org.eclipse.persistence.internal.sessions.AbstractSession.commitTransaction(AbstractSession.java:688)
>  at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitTransaction(UnitOfWorkImpl.java:1585)
>  at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitTransaction(RepeatableWriteUnitOfWork.java:629)
>  at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitTransactionAfterWriteChanges(UnitOfWorkImpl.java:1608)
>  at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.issueSQLbeforeCompletion(RepeatableWriteUnitOfWork.java:339)
>  at org.eclipse.persistence.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:157)
>  at org.eclipse.persistence.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:68)
>  at weblogic.transaction.internal.ServerSCInfo.doBeforeCompletion(ServerSCInfo.java:1214)
>  at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:1189)
>  at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:109)
>  at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1301)
>  at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:2117)
>  at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:257)
>  ... 64 more
>
> Thanks a lot,
>    Constantino.
>
> ------------------------------
>
> Message: 2
> Date: Wed, 1 Dec 2010 06:29:06 -0800 (PST)
> From: James Sutherland <jamesssss@xxxxxxxxx>
> To: eclipselink-users@xxxxxxxxxxx
> Subject: Re: [eclipselink-users] inactiveUnitOfWork with
>         OptimisticLockException
> Message-ID: <30349424.post@xxxxxxxxxxxxxxx>
> Content-Type: text/plain; charset=us-ascii
>
>
> That is odd, it code mean you have JTA configured incorrectly.  Are you using
> JPA or native API?  Include your persistence.xml, and how you commit the
> transaction/unit of work.
>
>
>
> Cronemberger, Constantino wrote:
>> Hi,
>>
>> When I get an OptimisticLockException trying to commit a transaction I
>> also get the following warning. Is this something I should wory about?
>>
>> ####<26-Nov-2010 15:15:39 o'clock BRST> <Warning> <JTA> <SPMADLT0374>
>> <AdminServer> <[ACTIVE] ExecuteThread: '1' for queue:
>> 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <>
>> <1290791739182> <BEA-110401> <Ignoring error in afterCompletion.
>> Object=<mailto:Object=org.eclipse.persistence.transaction.JTASynchronizationListener@a37e0d>org.eclipse.persistence.transaction.JTASynchronizationListener@a37e0d,
>> Exception=Exception [EclipseLink-23011] (Eclipse Persistence Services -
>> 2.1.0.v20100614-r7608):
>> org.eclipse.persistence.exceptions.TransactionException
>> Exception Description: UnitOfWork [UnitOfWork(
>>  DatabaseAccessor(connected)
>>  Oracle10Platform)] was rendered inactive before associated externally
>> managed transaction was complete.
>> Exception [EclipseLink-23011] (Eclipse Persistence Services -
>> 2.1.0.v20100614-r7608):
>> org.eclipse.persistence.exceptions.TransactionException
>> Exception Description: UnitOfWork [UnitOfWork(
>>  DatabaseAccessor(connected)
>>  Oracle10Platform)] was rendered inactive before associated externally
>> managed transaction was complete.
>>  at
>> org.eclipse.persistence.exceptions.TransactionException.inactiveUnitOfWork(TransactionException.java:118)
>>  at
>> org.eclipse.persistence.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:203)
>>  at
>> org.eclipse.persistence.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:79)
>>  at
>> weblogic.transaction.internal.ServerSCInfo.doAfterCompletion(ServerSCInfo.java:1023)
>> It also happened with version 2.2.0-M5.
>>
>> Thanks,
>>    Constantino
>>
>>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users


------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


End of eclipselink-users Digest, Vol 40, Issue 8
************************************************


Back to the top