Version is updated when a lazy, noop, inverse, one-to-many collection is mapped to an entity.

Description

An entity that contains a lazy, noop, inverse, one-to-many bag mapping is being flagged as dirty on flush, causing it's version to be updated. Test case(s) attached. The behavior exists when the entity is cached or non-cached.

This issue causes intermittent issues on some longer running tasks of our application because the unanticipated update causes lock contention on the table.

After some investigation, it appears the bag mappings are causing the entity to be identified as dirty, and the entity is being updated. The only update to the entity is the version. In my testing, the behavior was introduced in Hibernate 4.3.11 and has been in Hibernate 5.0.3 and beyond. I am curious if there is a possible linkage to HHH-9777.

Attachments

6
  • 28 Dec 2015, 07:49 PM
  • 28 Dec 2015, 07:49 PM
  • 28 Dec 2015, 07:49 PM
  • 28 Dec 2015, 07:49 PM
  • 28 Dec 2015, 07:49 PM
  • 28 Dec 2015, 07:49 PM

Activity

Show:

Donnchadh Ó Donnabháin June 20, 2017 at 6:16 PM

Adding optimistic-lock="false" to the noop-mapped field seems to resolve this, at least with Hibernate 5.1.7.Final .

Nick Kirsch December 28, 2015 at 7:57 PM
Edited

Would validating the checkable argument in the following isDirty implementaiton of CollectionType be enough to fix things? The lazy collections in my test case seem to have an empty checkable array, which I assume can be interpreted as not-checkable for dirty checking?

@Override public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { return isDirty(old, current, session); }

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created December 28, 2015 at 7:49 PM
Updated January 24, 2025 at 3:17 PM