Exception when changing composite collection with inverse
Added as test change-comp-collection-inverse-prop.app
Exception:
Submitted by Elmer van Chastelet on 24 September 2013 at 16:23[24 Sep 16:23:24 change-comp-collection-inverse-prop] ERROR exception during execution of action org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [webdsl.generated.domain.Item#42aee541-491e-472e-ae72-ca201369d78b] at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1230) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:188) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at utils.HibernateUtil$SetVersionSaveOrUpdateEventListener.onSaveOrUpdate(HibernateUtil.java:80) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:252) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:392) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:335) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:425) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:362) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:338) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204) at org.hibernate.engine.Cascade.cascade(Cascade.java:161) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:345) at com.sun.proxy.$Proxy39.flush(Unknown Source) at webdsl.generated.templates.root2_s_ad0String_Template$1.run(root2_s_ad0String_Template.java:243) at webdsl.generated.templates.root2_s_ad0String_Template.handleActionsInternal(root2_s_ad0String_Template.java:149) at utils.TemplateServlet.handleActions(TemplateServlet.java:88) at webdsl.generated.templates.wrapsubmitString_Template.handleActionsInternal(wrapsubmitString_Template.java:255) at utils.TemplateServlet.handleActions(TemplateServlet.java:88) at webdsl.generated.templates.root2_Template.handleActionsInternal(root2_Template.java:296) at utils.TemplateServlet.handleActions(TemplateServlet.java:88) at utils.AbstractPageServlet.serve(AbstractPageServlet.java:106) at utils.DispatchServletHelper.handlePage(DispatchServletHelper.java:387) at utils.DispatchServletHelper.doServe(DispatchServletHelper.java:349) at utils.DispatchServlet.doPost(DispatchServlet.java:287) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)
Issue Log
Maybe related to: https://svn.strategoxt.org/websvn/WebDSL?op=comp&compare[]=/webdsls/trunk/src/org/webdsl/dsl/to-java-servlet/java-entity-main.str@5667&compare[]=/webdsls/trunk/src/org/webdsl/dsl/to-java-servlet/java-entity-main.str@5668
part of the fix for allowing moving of composite items is a workaround to avoid triggering cascade orphan deletion in hibernate (found here https://forum.hibernate.org/viewtopic.php?f=1&t=1012422)
in generated Item.java, method setContainer(webdsl.generated.domain.Container newitem):
utils.HibernateUtil.getCurrentSession().flush(); UUID oldid = oldthing.getId(); utils.HibernateUtil.getCurrentSession().evict(oldthing); oldthing = (webdsl.generated.domain.Container) utils.HibernateUtil.getCurrentSession().load(webdsl.generated.domain.Container.class, oldid); oldthing.removeFromItems(this);
Disabling the test for now. We need better support for deletions in general before going into specific cases like this. This will require a solution outside of Hibernate to provide better detection and error reporting of referential integrity contraint violations, or custom delete cascading rules.
Log in to post comments