[hibernate-users] Problem persisting a set of object
Alex Turner
armtuk at gmail.com
Sun Nov 16 01:03:27 EST 2008
I have two questions:
1) I thought the entity at the source end of a OneToMany defined by
annotations didn't care about it's collection and would ignore updates to
the collection? (this is the first problem, I got around it by settings
cascade = CascadeType.ALL because if it does persist it's list that's not a
bad thing, it's just not what I was expecting)
2) After doing that, I get the following error. As far as I can tell all my
Entities have generated ids, so I don't really undefrstand how I could have
an object with a null id other than the fact that it's null because it has
yet to be populated with a generated id.
00:41:15:ERROR org.hibernate.AssertionFailure (AssertionFailure.java:22) -
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.onMerge(DefaultMergeEventListener.java:123)
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:228)
at com.tmdworldwide.projectmanager.persist.BaseDao.save(BaseDao.java:37)
at
com.tmdworldwide.projectmanager.web.product.ProductActionBean.createProject(ProductActionBean.java:49)
at
com.tmdworldwide.projectmanager.web.product.CreateTrifoldBrochureActionBean.createProject(CreateTrifoldBrochureActionBean.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
at
org.stripesstuff.plugin.security.SecurityInterceptor.interceptEventHandling(SecurityInterceptor.java:191)
at
org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:123)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
at
net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
at
net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:285)
at
net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServlet.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
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
net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:246)
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:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
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:447)
at java.lang.Thread.run(Thread.java:637)
00:41:15: WARN net.sourceforge.stripes.exception.DefaultExceptionHandler
(Log.java:90) - Unhandled exception caught by the Stripes default exception
handler.
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.onMerge(DefaultMergeEventListener.java:123)
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:228)
at com.tmdworldwide.projectmanager.persist.BaseDao.save(BaseDao.java:37)
at
com.tmdworldwide.projectmanager.web.product.ProductActionBean.createProject(ProductActionBean.java:49)
at
com.tmdworldwide.projectmanager.web.product.CreateTrifoldBrochureActionBean.createProject(CreateTrifoldBrochureActionBean.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
at
org.stripesstuff.plugin.security.SecurityInterceptor.interceptEventHandling(SecurityInterceptor.java:191)
at
org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:123)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
at
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at
net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
at
net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
at
net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:285)
at
net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServlet.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
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
net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:246)
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:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
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:447)
at java.lang.Thread.run(Thread.java:637)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-users/attachments/20081116/06b9c480/attachment.html
More information about the hibernate-users
mailing list