Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Cannot persist newly created object?
Cannot persist newly created object? [message #382525] Tue, 14 October 2008 17:47 Go to next message
Markus KARG is currently offline Markus KARG
Messages: 44
Registered: July 2009
Member
Using GlassFishv2/TopLink I have a severe problem...
From time to time TopLink says that it cannot persist a newly created (!)
object:

The code is:
final Clarification clarification = new Clarification(id, ...some
params...); <--- internally registers the "1-Sider" of the relation

this.getComplaint().getClarifications().add(clarification); <--- Registers
this new object at the "N-Side" of the relation

this.em.persist(clarification); <---- here it says "cannot persist detached
object"

....what looks pretty simple and works most of the time.

The Exception is:


Caused by: javax.persistence.EntityExistsException:
Exception Description: Cannot persist detached object
[de.quipsy.persistency.occuredCost.OccuredCost@fcd8ff].
Class> de.quipsy.persistency.occuredCost.OccuredCost Primary Key> [16]
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManag erImpl.persist(EntityManagerImpl.java:208)
at
com.sun.enterprise.util.EntityManagerWrapper.persist(EntityM anagerWrapper.java:440)
at
de.quipsy.application.complaint.complaintEditor.ComplaintEdi torBean.addClarification(ComplaintEditorBean.java:431)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.security.application.EJBSecurityManager.r unMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil .java:176)
at
com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod( BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer .java:3986)
at
com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJB ObjectInvocationHandler.java:203)
... 17 more
Caused by: Exception [TOPLINK-7231] (Oracle TopLink Essentials - 2.0.1
(Build b04-fcs (04/11/2008))):
oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot persist detached object
[de.quipsy.persistency.occuredCost.OccuredCost@fcd8ff].
Class> de.quipsy.persistency.occuredCost.OccuredCost Primary Key> [16]
at
oracle.toplink.essentials.exceptions.ValidationException.can notPersistExistingObject(ValidationException.java:2171)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java: 3251)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableW riteUnitOfWork.registerNotRegisteredNewObjectForPersist(Repe atableWriteUnitOfWork.java:339)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNewObjectForPersist(UnitOfWorkImpl.java:3220)
at
oracle.toplink.essentials.mappings.CollectionMapping.cascade RegisterNewIfRequired(CollectionMapping.java:265)
at
oracle.toplink.essentials.internal.descriptors.ObjectBuilder .cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNewObjectForPersist(UnitOfWorkImpl.java:3226)
at
oracle.toplink.essentials.mappings.CollectionMapping.cascade RegisterNewIfRequired(CollectionMapping.java:265)
at
oracle.toplink.essentials.internal.descriptors.ObjectBuilder .cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNewObjectForPersist(UnitOfWorkImpl.java:3226)
at
oracle.toplink.essentials.mappings.CollectionMapping.cascade RegisterNewIfRequired(CollectionMapping.java:265)
at
oracle.toplink.essentials.internal.descriptors.ObjectBuilder .cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNewObjectForPersist(UnitOfWorkImpl.java:3226)
at
oracle.toplink.essentials.mappings.CollectionMapping.cascade RegisterNewIfRequired(CollectionMapping.java:265)
at
oracle.toplink.essentials.internal.descriptors.ObjectBuilder .cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
at
oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.r egisterNewObjectForPersist(UnitOfWorkImpl.java:3226)
at
oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManag erImpl.persist(EntityManagerImpl.java:205)
... 28 more
|#]

In fact I have no idea what my fault could be or what to check...

Any ideas...?

Thanks!
Markus
Re: Cannot persist newly created object? [message #382527 is a reply to message #382525] Wed, 15 October 2008 14:03 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The error essentially means that there is already an existing object with
the same id. How is your object's id assigned?

--
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Previous Topic:JPA QL Question
Next Topic:self referencing entiy
Goto Forum:
  


Current Time: Sat Sep 20 00:03:38 GMT 2014

Powered by FUDForum. Page generated in 0.01884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software