Invalid entity being created when merging with recursive cascading
Description
Attachments
3
caused by
is a fix for
Activity
Show:

Former user August 30, 2016 at 12:03 AM
Fixed in 5.1 and 5.0 branches as well.
Vlad Mihalcea June 6, 2016 at 2:58 PM
Applied PR upstream.
Vlad Mihalcea May 30, 2016 at 1:49 PM
Why do you want to cascade from a child to a parent? This makes me wonder what could be a possible use case for this. Usually events need to be cascaded from parent to childs, not the other way around.

Alex Belyaev November 1, 2015 at 12:34 PM
I've checked 5.0.3.Final, the issue is still there. I have also uploaded new test (hibernate-recursive-cascade-5.0.3.zip) that uses hibernate 5.0.3.Final.
Steve Ebersole October 28, 2015 at 3:25 AM
As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.
Consider 2 'parent' and 'child' entities:
There is a bidirectional relation with cascade=all on both sides. In some cases, on attempt to do a merge operation on a mixed (attached/transient) graph of these kind of entities, two managed entities are being created for single transient 'parent' entity.
The easiest way to see what's going on is to examine attached test.
Set breakpoint to bug.CascadeAttachedDetachedTest.java:70 and run this test. When breakpoint fires, examine contents of the 'managedVehicle' object (see attached managedVehicle_bad_transport.png):
Here we see two attached entities created for transient $2to3 entity. The first one (managedVehicle.transports[0]) is valid. The second one (managedVehicle.transports[0].pickupNode.pickupTransports[0]) is invalid (all fields, including ID is null). Next step (s.flush() ) will result in 'not-null property name is null' error for that entity.