geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maho77 <m.hoffm...@mvolution.de>
Subject Re: EntityExistsException: Attempt to persist detached object
Date Mon, 26 Nov 2007 08:47:29 GMT



Jacek Laskowski wrote:
> 
> On Nov 22, 2007 7:52 PM, maho77 <m.hoffmann@mvolution.de> wrote:
> 
>>  I have already tried em.persist(em.merge(group)). It didn't work. I the
>> meantime I found out that the problem obviously lies in the
>> @TableGenerator
>> thing. I removed it and set the id by hand and it worked fine. So I hope
>> your right. with the primary key.
>> So only to understand it right, do I have to set the
>> private int id = 0;
>> by hand or is the attribute in the @TableGenerator enough. I ask because
>> I
>> tried it with private int id; which also refused to work. On monday I
>> will
>> be back in the office and try it.
> 
> I need to try it out myself too as it could be an issue with our
> integration with openjpa. Anyway, don't touch primary key of the
> entity as it's reserved for a jpa provider's use. Let the default
> initial value be set for it.
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
> 
> 

Hello,

I tried it with an unitialized id field and ran into another exception:

09:40:29,126 WARN  [Transaction] Unexpected exception from beforeCompletion;
transaction will roll back
<openjpa-1.0.0-r420667:568756 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: null
	at
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:162)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:341)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:247)
	at
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)
	at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
	at
org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:557)
	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:450)
	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:426)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:541)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
	at
org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:501)
	at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2770)
	at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
	at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1884)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1762)
	at
org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
	at
org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
	at
org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
	at
org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
	at
org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:239)
	at
org.apache.openejb.core.transaction.TransactionPolicy.commitTransaction(TransactionPolicy.java:140)
	at
org.apache.openejb.core.transaction.TxRequired.afterInvoke(TxRequired.java:75)
	at
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:219)
	at
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
	at
org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:212)
	at
org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:120)
	at
org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:164)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:122)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
	at org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:73)
	at
org.apache.openejb.server.ServiceAccessController.service(ServiceAccessController.java:55)
	at org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:117)
	at java.lang.Thread.run(Thread.java:810)
Caused by: 
javax.transaction.SystemException
	at
org.apache.openjpa.ee.RegistryManagedRuntime$TransactionManagerRegistryFacade.suspend(RegistryManagedRuntime.java:176)
	at
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:158)
	... 36 more
09:40:29,127 INFO  [Transaction] The transaction has been rolled back rather
than commited: Unable to commit: transaction marked for rollback

I also inserted an Sysoute in the setId()-Method. This sysout will never be
called. I work with a MySQL 5 server.

Mark



-- 
View this message in context: http://www.nabble.com/EntityExistsException%3A-Attempt-to-persist-detached-object-tf4856534s134.html#a13945943
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message