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 = true setting, null and empty component should be treated the same in dirty checking. (ref: http://in.relation.to/2016/02/10/hibernate-orm-510-final-release/#embeddables-and-all-null-column-values) - the entity has @SelectBeforeUpdate and @Embedded property - a object is retrieved with empty embedded property - the object is detached and then session Note this issue arises for both settings . update(obj) is called without any change i.e. hibernate.create_empty_composites.enabled=true/false.
This bug has a serious consequence of updating audit information incorrectly (with or without envers.) |
|