openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: How to persist then update in same transaction
Date Mon, 31 Aug 2009 19:41:21 GMT
When running your application in JSE mode, are you calling
em.getTransaction().begin(commit())? I'm willing to bet you aren't and that
is why your test works in JSE, but fails on WAS.

-Rick

On Mon, Aug 31, 2009 at 12:48 PM, Diane J <jewettdiane@gmail.com> wrote:

>
> I do the following in one transaction:
>
> OrgType orgType = new OrgType();
> getOrgTypeDAO().persist(orgType);
> Organization org = new Organization();
> org.setOrgName("Test");
> org.setOrgTypeId(orgType.getOrgTypeId());
> getOrganizationDAO().persist(org);
> orgType.setOwnerOrgId(org.getOrgId());
> getOrgTypeDAO().merge(orgType);
>
> And the merge throws this exception:
>
>  WTRN0074E: Exception caught from before_completion synchronization
> operation: <openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal user error>
> org.apache.openjpa.persistence.InvalidStateException: The generated value
> processing detected an existing value assigned to this field:
> com.adp.ei9.common.entity.OrgType.orgTypeId.  This existing value was
> either
> provided via an initializer or by calling the setter method.  You either
> need to remove the @GeneratedValue annotation or modify the code to remove
> the initializer processing.
>        at
> org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:483)
>        at
> org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:463)
>        at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:682)
>        at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:519)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2823)
>        at
> org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:959)
>        at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1948)
>        at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
>        at
> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
>        at
>
> com.ibm.ws.uow.ComponentContextSynchronizationWrapper.beforeCompletion(ComponentContextSynchronizationWrapper.java:65)
>        at
>
> com.ibm.tx.jta.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:289)
>        at
>
> com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:150)
>        at
> com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2222)
>        at
>
> com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:486)
>        at
> com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:978)
>        at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:913)
>        at
> com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:369)
>        at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161)
>        at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:915)
>        at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:228)
>        at
>
> com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:561)
>        at
> com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4512)
>        at
>
> com.adp.ei9.esb.test.EJSLocalStatelessJPATester_80c7ee76.testPersistAndMergeOwnerId(EJSLocalStatelessJPATester_80c7ee76.java:138)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>        at java.lang.reflect.Method.invoke(Method.java:599)
>        at
>
> com.ibm.etools.utc.model.ReflectionMethodModel.invoke(ReflectionMethodModel.java:65)
>        at
> com.ibm.etools.utc.servlet.InvokeServlet.invoke(InvokeServlet.java:113)
>        at
> com.ibm.etools.utc.servlet.InvokeServlet.doPost(InvokeServlet.java:374)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
>        at
>
> com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
>        at
>
> com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
>        at
>
> com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
>        at
>
> com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
>        at
>
> com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
>        at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
>        at
>
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
>        at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
>        at
>
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
>        at
>
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
>        at
>
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
>        at
>
> com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1772)
>        at
>
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
>        at
>
> com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
>        at
>
> com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
>        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
>        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
>        at
>
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
>        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
>        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
>
>
> This is expected to have a generated id because I already persisted the
> entity. This only fails on websphere and not in my testcase where the
> transactions are not set to managed.
>
> These are my jpa props:
>                                <entry key="openjpa.TransactionMode"
> value="managed" />
>                                <entry key="openjpa.ConnectionFactoryMode"
> value="managed" />
>                                <entry key="openjpa.jdbc.UpdateManager"
> value="operation-order" />
>
> My test jpa props are:
>                                <entry
> key="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />
>                                <entry key="openjpa.jdbc.DBDictionary"
>
>
> value="org.apache.openjpa.jdbc.sql.H2Dictionary(useGetObjectForBlobs=false)"
> />
>                                <entry key="openjpa.jdbc.UpdateManager"
> value="operation-order" />
>
>
> --
> View this message in context:
> http://n2.nabble.com/How-to-persist-then-update-in-same-transaction-tp3555069p3555069.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message