If using the config option global_with_modified_flag, envers creates erronous audit entries for ManyToMany relations in certain cases. Suppose EntityA and EntityB are related via a ManyToMany relation and EntityA is the owning side of the relation. In this case I can remove an EntityB from the relation, persist the EntityA and the relation is updated correctly. If envers is configured with `global_with_modified_flag, it creates 3 audit entries, one for the relation, one for the owning and one for the owned side. The audit entry for the owned side does not contain any data except for id, rev, revtype and the *_mod fields. The _mod field that corresponds to the relation is set to true like it is expected. All other fields are null. I would expect that all other fields are filled with the current values. I wrote a reproducer for this problem, the last assert fails: https://github.com/simonseyock/hibernate-test-case-templates/blob/many-to-many-pk/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java If anyone can help me with a workaround for this, I would be very thankful. |