Uploaded image for project: 'Lucee Development'
  1. LDEV-1229

ORM: Error when updating an entity with 1-many children and 'delete-orphan' or 'all-delete-orphan' cascade

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.2.24
    • Fix Version/s: Hibernate 3.5.5.64, 5.2.3.11
    • Labels:
    • Environment:

      Lucee 5.1.2.24
      Windows 10, Java 1.8 (u121), Tomcat 8.5.11
      Hibernate extension: 3.5.5.63

    • Sprint:
      July 2017 Sprint

      Description

      If an already persisted entity has a one-to-many relationship defined with a cascade of either delete-orphan or all-delete-orphan, updating it throws an error.

      For example, saving a loaded parent entity with a property definition such as

      //Parent.cfc
      property name="children" singularName="child" fieldType="one-to-many" cfc="Child" fkColumn="parentID" inverse="true" cascade="all-delete-orphan";
      

      ..results in an error:

      "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: Parent.children".

      Full stack trace:

      lucee.runtime.exp.NativeException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: Parent.children
       	at org.hibernate.engine.Collections.processDereferencedCollection(Collections.java:118)
       	at org.hibernate.engine.Collections.processUnreachableCollection(Collections.java:62)
       	at org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:241)
       	at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:100)
       	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
       	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
       	at org.lucee.extension.orm.hibernate.HibernateORMTransaction.end(HibernateORMTransaction.java:45)
       	at lucee.runtime.orm.ORMConnection.setAutoCommit(ORMConnection.java:214)
       	at lucee.runtime.db.DatasourceManagerImpl.end(DatasourceManagerImpl.java:272)
       	at lucee.runtime.tag.Transaction.doFinally(Transaction.java:157)
       	at bugs.orm.index_cfm$cf.call(/bugs/orm/index.cfm:5)
       	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:924)
       	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:838)
       	at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:226)
       	at lucee.runtime.listener.ModernAppListener.onRequest(ModernAppListener.java:103)
       	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2394)
       	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2385)
       	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2353)
       	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:907)
       	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
       	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:62)
       	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
       	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
       	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
       	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
       	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
       	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
       	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
       	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
       	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
       	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
       	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
       	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
       	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
       	at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:478)
       	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
       	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
       	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
       	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
       	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
       	at java.lang.Thread.run(Thread.java:745)
      

      Running the same code under Lucee 4.5 works fine.

      Test case attached.

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              julianhalliwell Julian Halliwell
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: