|
Hibernate Envers, setup with 'withModifiedFlag' = 'true, has a different behaviour when a detached entity (annotated with @Audited) is modified
and persisted by session.update() method or by session.merge() method.
Specifically merge() method works correctly as expected:
-if I modify a entity's property, the corresponding "property_MOD" field inserted into "entity_AUD" table is valued 'true'
-whereas it is valued 'false' if the entity's property isn't modified.
update() (but also saveOrUpdate()) method works in wrong way:
-the "property_MOD" field is valued 'true' if the corresponding entity's property is not null, indipendently if i have modified it or not.
-otherwise it is valued 'false' if the corrispondent entity's property is null, indipendently if i have modified it or not.
I created a simple test case.
-There is only one entity, Address class, flagged with 'withModifiedFlag' attribute.
-The test case creates 2 Address instances.
-After that one of these is modified.
-Then, the test case checks that only one Address instance is modified at revision 2. If it uses merge() method, it will have green bar; if it uses update() method, it will have red bar.
For more details go to the Hibernate Envers community forum:
https://community.jboss.org/thread/229595
|