Can you post the source for ProcessDAOImpl? Also, are there any other OpenJPA properties in your configuration? Finally, I'm assuming that you're using a somewhat-current 0.9.7-SNAPSHOT. Correct me if I'm wrong.
> But shouldn't I worry about the fact that a brand new > instance is detached? I could be wrong but it looks > like it's more a symptom of I believe that you should. I think I remember reading something about this recently, but I don't remember the details. My suspicion is that you don't have an @Version field, and you're using the default detach manager. IIRC, this combination leaves OpenJPA with no way to detect a detached object vs. a new object, and we default to detached. I thought that we had improved the docs around this at the least; certainly, it'd be good to figure out your particulars and make sure that this is clearer for others. (IIRC, the default detach manager uses a heuristic on the value in the version field to determine whether an instance is new or detached. OpenJPA supports more flexible detach managers that can do fun things like providing useful errors when attempting to navigate past the end of a detached object graph, and fine-grained tracking of changes made while detached. But it's not serialization-compatible with the unenhanced code, meaning that you need to put the enhanced classes into your client tier, which I think that we decided was a bad default.) -Patrick -- Patrick Linskey BEA Systems, Inc. _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. > -----Original Message----- > From: Matthieu Riou [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 28, 2007 7:50 PM > To: Pinaki Poddar > Cc: open-jpa-dev@incubator.apache.org > Subject: Re: OpenJPA & Transaction configuration > > Thanks! But shouldn't I worry about the fact that a brand new > instance is > detached? I could be wrong but it looks like it's more a symptom of > something wrong in my configuration, no? > > On 2/28/07, Pinaki Poddar <[EMAIL PROTECTED]> wrote: > > > > instead of _em.persist(ret); > > try > > _em.merge(ret); > > > > as ret is detached instance rather than new. > > > > > > > > Pinaki Poddar > > BEA Systems > > 415.402.7317 > > > > > > -----Original Message----- > > From: Matthieu Riou [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, February 28, 2007 6:29 PM > > To: open-jpa-dev@incubator.apache.org > > Subject: OpenJPA & Transaction configuration > > > > Hi, > > > > I'm going back at the OpenJPA implementation for the Apache > ODE project > > and am still having problems with the setup. Whan I try to > persist a new > > object I get an exception "Attempt to persist detached > object". I guess > > the when I instantiate my object OpenJPA can't locate its > transactional > > context or something related therefore assuming that the object is > > instantiated outside of any persistent context. > > > > Here is the code that creates the EntityManagerFactory: > > > > HashMap<String, Object> propMap = new > HashMap<String,Object>(); > > propMap.put("openjpa.Log", "DefaultLevel=TRACE"); > > propMap.put("openjpa.jdbc.DBDictionary", " > > org.apache.openjpa.jdbc.sql.DerbyDictionary"); > > propMap.put("openjpa.ManagedRuntime", new TxMgrProvider()); > > propMap.put("openjpa.ConnectionFactory", _ds); > > propMap.put("openjpa.ConnectionFactoryMode", "managed"); > > propMap.put("openjpa.Log", "DefaultLevel=TRACE"); > > _emf = Persistence.createEntityManagerFactory("ode-dao", > > propMap); > > > > And here is my object instantiation code: > > > > ProcessDAOImpl ret = new > > ProcessDAOImpl(pid,type,guid,this,version); > > System.out.println("detached " + > > ((PersistenceCapable)ret).pcIsDetached()); > > _em.persist(ret); > > > > My little debugging statement outputs "true". I've > reproduced the full > > log below. I've also encapsulated to transaction manager and the > > transaction to check whether OpenJPA was getting the transaction and > > registering a synchronizer properly. It seems to be doing > so (the log > > statements are just a couple lines above the '.....'). I've > removed all > > the mapping logs just to avoid making this too lengthy. > > > > Any idea of what the problem could be? I'm kind of stuck on > this as it's > > hard to debug the enhanced code that gets called when I > instantiate my > > process object. > > > > DEBUG - ODEMessageReceiver.receive(47) | Received message for > > helloWorld.hello DEBUG - > ODEService.onAxisMessageExchange(96) | Starting > > transaction. > > DEBUG - BpelEngineImpl.route(237) | Routed: svcQname { > > http://ode/bpel/unit-test.wsdl}HelloService --> BpelProcess[{ > > http://ode/bpel/unit-test}HelloWorld2-1] > > 29603 ode-dao INFO [http-8080-Processor25] openjpa.Runtime - > > Starting > > OpenJPA 0.9.7-incubating-SNAPSHOT > > 29604 ode-dao TRACE [http-8080-Processor25] openjpa.Runtime - > > Properties: > > openjpa.EntityManagerFactory: default > > openjpa.DataCache: false > > openjpa.MetaDataFactory: jpa(Types= > > org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl > > > ;org.apache.ode.dao.jpa.CorrelationSetDAOImpl;org.apache.ode.d > ao.jpa.Cor > > > relatorDAOImpl;org.apache.ode.dao.jpa.EventDAOImpl;org.apache. > ode.dao.jp > > > a.FaultDAOImpl;org.apache.ode.dao.jpa.MessageDAOImpl;org.apach > e.ode.dao. > > > jpa.MessageExchangeDAOImpl;org.apache.ode.dao.jpa.MessageRoute > DAOImpl;or > > > g.apache.ode.dao.jpa.PartnerLinkDAOImpl;org.apache.ode.dao.jpa > .ProcessDA > > > OImpl;org.apache.ode.dao.jpa.ProcessInstanceDAOImpl;org.apache > .ode.dao.j > > pa.ScopeDAOImpl;org.apache.ode.dao.jpa.XmlDataDAOImpl) > > openjpa.InverseManager: false > > openjpa.ReadLockLevel: read > > openjpa.DataCacheManager: default > > openjpa.jdbc.SubclassFetchMode: join > > openjpa.jdbc.UpdateManager: default > > openjpa.jdbc.SynchronizeMappings: false > > openjpa.NontransactionalRead: true > > openjpa.QueryCompilationCache: true > > openjpa.MaxFetchDepth: -1 > > openjpa.RetainState: true > > openjpa.DynamicDataStructs: false > > openjpa.BrokerFactory: jdbc > > openjpa.WriteLockLevel: write > > openjpa.ManagedRuntime: > > org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl$TxMgrProvider > > openjpa.jdbc.EagerFetchMode: parallel > > openjpa.RestoreState: immutable > > openjpa.jdbc.SchemaFactory: dynamic > > openjpa.LockManager: version > > openjpa.BrokerImpl: default > > openjpa.NontransactionalWrite: true > > openjpa.MetaDataRepository: default > > openjpa.Log: true(DefaultLevel=TRACE) > > openjpa.jdbc.ResultSetType: forward-only > > openjpa.AutoDetach: > > openjpa.ConnectionRetainMode: on-demand > > openjpa.SavepointManager: in-mem > > openjpa.jdbc.DBDictionary: derby > > openjpa.Optimistic: true > > openjpa.ConnectionFactoryMode: managed > > openjpa.Sequence: table > > openjpa.FetchGroups: default > > openjpa.jdbc.Schemas: > > openjpa.Id: ode-dao > > openjpa.OrphanedKeyAction: log > > openjpa.FlushBeforeQueries: true > > openjpa.AutoClear: datastore > > openjpa.Compatibility: default > > openjpa.DetachState: loaded > > openjpa.jdbc.LRSSize: query > > openjpa.Multithreaded: false > > openjpa.FetchBatchSize: -1 > > openjpa.jdbc.SQLFactory: default > > openjpa.IgnoreChanges: false > > openjpa.jdbc.MappingDefaults: jpa > > openjpa.TransactionMode: local > > openjpa.RetryClassRegistration: false > > openjpa.jdbc.FetchDirection: forward > > openjpa.ClassResolver: default > > openjpa.LockTimeout: -1 > > openjpa.DataCacheTimeout: -1 > > openjpa.QueryCache: true > > openjpa.jdbc.DriverDataSource: simple > > openjpa.jdbc.TransactionIsolation: default > > openjpa.ProxyManager: default > > 29604 ode-dao TRACE [http-8080-Processor25] > openjpa.MetaData - Using > > metadata factory " > > > org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@ > 1742ad8". > > 29604 ode-dao INFO [http-8080-Processor25] > openjpa.jdbc.JDBC - Using > > dictionary class "org.apache.openjpa.jdbc.sql.DerbyDictionary". > > WARN - > BPELDAOConnectionFactoryImpl$DebugTxMgr.getTransaction(130) | JPA > > get transaction WARN - > > BPELDAOConnectionFactoryImpl$DebugTx.registerSynchronization(179) | > > Synchronization registration on org.apache.openjpa.kernel.BrokerImpl > > WARN - > BPELDAOConnectionFactoryImpl$DebugTx.registerSynchronization(179) > > | Synchronization registration on > > > org.apache.openjpa.kernel.AbstractBrokerFactory$RemoveTransactionSync > > 29610 ode-dao INFO [http-8080-Processor25] > openjpa.MetaData - Found > > 13 > > classes with metadata in 0 milliseconds. > > 29834 ode-dao TRACE [http-8080-Processor25] openjpa.MetaData - > > Loading metadata for "class > > org.apache.ode.dao.jpa.MessageExchangeDAOImpl" under mode > > "[META][QUERY]". > > .......... > > .......... > > 30386 ode-dao TRACE [http-8080-Processor25] openjpa.jdbc.SQL - <t > > 9601173, conn 16542562> executing prepstmnt 6493766 SELECT t0.ID, > > t0.VERSION, t0.GUID, t0.NUMBER_OF_INSTANCES, t0.PROCESS_ID, > > t0.PROCESS_TYPE FROM ODE_PROCESS t0 WHERE (t0.PROCESS_ID = ?) > > [params=(String) { http://ode/bpel/unit-test}HelloWorld2-1] > > 30387 ode-dao TRACE [http-8080-Processor25] openjpa.jdbc.SQL - <t > > 9601173, conn 16542562> [0 ms] spent > > 30388 ode-dao TRACE [http-8080-Processor25] > openjpa.jdbc.JDBC - <t > > 9601173, conn 16542562> [0 ms] close detached true WARN - > > BPELDAOConnectionFactoryImpl$DebugTxMgr.getTransaction(130) > | JPA get > > transaction ERROR - BpelServerImpl.bounceProcessDAO(334) | DbError > > <2|false|0.9.7-incubating-SNAPSHOT> > > org.apache.openjpa.persistence.EntityExistsException: > Attempt to persist > > detached object "[EMAIL PROTECTED]". > > FailedObject: [EMAIL PROTECTED] > > at > > org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2346) > > at > > org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2204) > > at org.apache.openjpa.kernel.DelegatingBroker.persist( > > DelegatingBroker.java:991) > > at org.apache.openjpa.persistence.EntityManagerImpl.persist( > > EntityManagerImpl.java:525) > > at org.apache.ode.dao.jpa.BPELDAOConnectionImpl.createProcess( > > BPELDAOConnectionImpl.java:78) > > > > Thanks! > > Matthieu > > > ______________________________________________________________ > _________ > > Notice: This email message, together with any attachments, > may contain > > information of BEA Systems, Inc., its subsidiaries and > affiliated > > entities, that may be confidential, proprietary, > copyrighted and/or > > legally privileged, and is intended solely for the use of > the individual > > or entity named in this message. If you are not the > intended recipient, > > and have received this message in error, please immediately > return this > > by email and then delete it. > > >