Cascade delete does not work for instrumented/enhanced entities

Description

We are in the process on migrating our app to hibernate 5 and we found an issue with cascade delete on instrumented entities.
After some more trials, it appears that this problem happens when we use annotations on the fields. When using annotations on the properties it works fine.

Note that I have tried other hibernate versions and the problem only appeared with hibernate 5.
More precisely it seems that this line in cfg\annotations\CollectionBinder.java:
binder.setLazy( collection.isLazy() );
which was added to the bind() method in hibernate 5 is related to the problem.

I have attached 2 TestCase: one that is working with annotations on the properties and one that is failing with annotations on the fields.
Note that those TestCases use instrumentation but the same problem happens with enhancement.

Attachments

2
  • 11 Nov 2015, 03:59 PM
  • 03 Nov 2015, 06:10 PM

Activity

Former userDecember 17, 2015 at 1:11 AM

Fixed in master and 5.0 branch.

Luis BarreiroDecember 10, 2015 at 11:02 AM

You're absolutely right. Thanks for pointing out.

The correct PR is https://github.com/hibernate/hibernate-orm/pull/1186

Andrei IvanovDecember 10, 2015 at 9:51 AM

Is this the correct PR? I don't see a fetchAttribute() method in the changes slightly smiling face

Luis BarreiroDecember 10, 2015 at 12:07 AM

PR sent with test case and fix. It exposes a fetchAttribute() method on the LazyAttributeLoadingInterceptor. The name 'fetch' (in opposition to 'load') is to make a distinction, because due to the way interception works the attribute is not associated with the entity (for the cascading it's not necessary that).

https://github.com/hibernate/hibernate-orm/pull/1183

Juan AMATNovember 19, 2015 at 7:15 PM

OK. Deprecating is better.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Created November 3, 2015 at 6:11 PM
Updated December 17, 2015 at 2:54 AM
Resolved December 17, 2015 at 1:11 AM

Flag notifications