-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Exc: cannot copy a reference to an object with a null id
PostPosted: Thu Apr 09, 2009 5:14 am 
Newbie

Joined: Thu Apr 09, 2009 4:56 am
Posts: 5
Hi,

I'm receiving the following exception while calling entitymanager.merge() for a tree of objects with parent childs relationschips. Could someone tell me in what case this exception is thrown?


2009-04-09 10:59:59,797 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)

org.hibernate.AssertionFailure: cannot copy a reference to an object with a null id

at org.hibernate.type.EntityType.replace(EntityType.java:255)

at org.hibernate.type.AbstractType.replace(AbstractType.java:153)

at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:564)

at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:240)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:687)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)

at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)

at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)

at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascade(Cascade.java:130)

at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:194)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:240)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:687)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)

at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)

at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)

at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascade(Cascade.java:130)

at org.hibernate.event.def.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:407)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:266)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:687)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)

at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)

at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)

at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)

at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)

at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)

at org.hibernate.engine.Cascade.cascade(Cascade.java:130)

at org.hibernate.event.def.DefaultMergeEventListener.cascadeOnMerge(DefaultMergeEventListener.java:407)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:266)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)

at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227)

at org.jboss.ejb3.entity.ExtendedEntityManager.merge(ExtendedEntityManager.java:106)

at org.jboss.seam.persistence.EntityManagerProxy.merge(EntityManagerProxy.java:130)

at com.hitec.u2010.ds.session.DomainMgrImpl.updateDomain(DomainMgrImpl.java:246)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)

at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)

at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)

at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)

at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)

at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)

at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)

at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)

at $Proxy122.updateDomain(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)

at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)

at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)

at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)

at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)

at org.javassist.tmp.java.lang.Object_$$_javassist_2.updateDomain(Object_$$_javassist_2.java)

at com.hitec.u2010.ds.webservice.InterDirectoryServiceImpl.updateDomain(InterDirectoryServiceImpl.java:175)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)

at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)

at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)

at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:101)

at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)

at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)

at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)

at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)

at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)

at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)

at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)

at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)

at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)

at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

at java.lang.Thread.run(Unknown Source)

Could this error come from a missing reference to a parent? After debuging I don't think I have any entity in the tree with a null Id.

Thanks
J.


Top
 Profile  
 
 Post subject: Exc: cannot copy a reference to an object with a null id
PostPosted: Fri Apr 10, 2009 9:41 am 
Newbie

Joined: Thu Apr 09, 2009 4:56 am
Posts: 5
It looks like it is due to a Cascading issue.
My definition of the relation between childs and parents is the following:
----------------------
relation in child class
---
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Parent.class)
@JoinColumn(name = "parent_id", nullable = false, referencedColumnName="id")
@NotNull
public Parent getParent() {
return this.parent;
}

public void setParent(Parent Parent) {
this.parent = parent;
}
---------------------
relation in parent class
----
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, mappedBy = "parent")
public Set<Child> getChilds() {
return this.childs;
}

public void setChilds(Set<Child> childs) {
this.childs= childs;
}
--------------------
The parent is allready saved in the database.
When I try to merge the child, I have the above Exception.
The childs is merged with a parent entity object containing the same id as the parent saved in database.

Has someone any clue?
I'm dealing with this problem this far too long please help!

Thanks
J.


Top
 Profile  
 
 Post subject: Exc: cannot copy a reference to an object with a null id
PostPosted: Thu Apr 16, 2009 11:19 am 
Newbie

Joined: Thu Apr 09, 2009 4:56 am
Posts: 5
Ok, this one was a very dumb one.

I initialized inexplicabely one of my parameter in one of my entities with its constructor.
That was creating the exception during cascaded merge as the reference to the entity was there but the id wasn't.

Example of bad declaration:

----------
@Entity
public class Example implements java.io.Serializable {

private Integer id;
private Param param= new Param();
--------


Hope this will help if it ever happen to someone else.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.