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 arises for both settings does not occur if the same updates are done within a session . i Only occurs when updating detached objects . e. hibernate.create_empty_composites.enabled=true/false.
This Note, this bug has a serious consequence of updating audit information incorrectly (with or without envers.) |
|