Uploaded image for project: 'Hibernate ORM'
  1. HHH-11237

Incorrect update occurs when updating a detached object with empty component and @SelectBeforeUpdate


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.4, 5.1.3, 5.2.5, 5.2.7
    • Fix Version/s: 5.2.8
    • Component/s: hibernate-core
    • Labels:
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
    • Sprint:


      Hibernate updates objects incorrectly on the following condition:

      • the entity has @SelectBeforeUpdate and @Embedded property.
      • there is an object whose properties in the embedded component are all null.
      • the object is retrieved and detached.
      • the object is either unchanged, null component set to empty component, or empty component set to null
      • the object is saved with session.update(obj)
        Then actual database update should not occur, but it does.

      Note that with the introduction of hibernate.create_empty_composites.enabled setting,
      null and empty component should be treated the same in dirty checking.
      This issue exists for both cases: i.e. hibernate.create_empty_composites.enabled=true/false.
      (ref: http://in.relation.to/2016/02/10/hibernate-orm-510-final-release/#embeddables-and-all-null-column-values)

      Note that this issue does not occur if the same updates are done within a session.
      Only occurs when updating detached objects.

      Note, this bug has a serious consequence of updating audit information incorrectly.
      The issue probably exists in hibernate-core, but hibernate-envers is also affected.

      Maybe org.hibernate.type.CompositeType.isModified is to be fixed?

      Attached the test case. Please check. Thank you.


          Issue links



              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: