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

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

..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:

Running the same code under Lucee 4.5 works fine.

Test case attached.

Environment

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

Activity

Show:
Luis Majano
June 6, 2017, 7:26 PM

I can duplicate this on 5.2.1.9 and completely breaks ContentBox CMS. You can see our tests here that fail: https://github.com/coldbox-modules/cbox-cborm/blob/development/tests/specs/BaseORMServiceTest.cfc and our models: https://github.com/coldbox-modules/cbox-cborm/tree/development/models/entities

Michael Offner
July 17, 2017, 3:37 PM

also see this on command line

Michael Offner
July 18, 2017, 6:55 AM

problem caused by

Michael Offner
July 18, 2017, 6:55 AM
Da Li
August 25, 2017, 2:54 AM
Edited

I upgraded to 5.2.4.15-SNAPSHOT from stable release 5.2.2.71 and found ORM acting weird, the relationship in the link table was somehow REMOVED. And I observed the following SQL statement in CommandBox console:

In my scenario, a user can have many companies and a company can have many users, so in my User.cfc bean:

Once I downgraded back to 5.2.2.71, the scary DELETE sql disappears.

I suspect that it has something to do with this ticket.

I've just started using ORM, so maybe there are flaws in my many-to-many relationship part, I can't tell for sure for the moment. Anyway, just little heads-up here.

Fixed

Assignee

Michael Offner

Reporter

Julian Halliwell

Priority

Major

Labels

Fix versions

Sprint

None

Affects versions

Configure