Enverse: Wrong Auditing of @ManyToMany or ElementCollection Fileds

Hi everyone,

We are using Hibernate Envers 6.1.7.Final for our Auditing functionality. The Problem we’re facing right now is the following:

We have an Audited Entity (provided below) that contains some ManyToMany / ElementCollection Fields that also need to be audited. However, when I change the value of any filed (e.g. changing name from “x” to “y”), Envers detects that change, and it marks also all ManyToMany / ElementCollection Fields as changed. This is not true. They should not be marked as changed.

The Entity:

@Entity
@Audited(withModifiedFlag = true)
public abstract class Element {
  @Id
  private Long id;
  private String name;

  @ElementCollection
  @CollectionTable(
      name = "element_tags",
      joinColumns = @JoinColumn(name = "element_id", referencedColumnName = "id"),
      foreignKey = @ForeignKey(name = "fk_element_tags_on_element_id"))
  private List<String> tags = new ArrayList<>();

  @ManyToMany
  @OrderBy("plannedEnd asc")
  @JoinTable(
      name = "element_milestones",
      joinColumns = @JoinColumn(name = "element_id", referencedColumnName = "id"),
      inverseJoinColumns =
      @JoinColumn(name = "milestone_id", referencedColumnName = "milestone_id"),
      foreignKey = @ForeignKey(name = "fk_element_milestones_on_element_id"),
      inverseForeignKey = @ForeignKey(name = "fk_element_milestones_on_milestone_id"))
  private Set<Milestone> milestones = new HashSet<>();
...
}

Am I doing something wrong that’s causing this issue? Or is it a limitation in HN Envers?

Any help or hint is highly appreciated!

Thanks in Advance

Please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

Done. Thanks for your response.

Hi @Abu , I’m facing with the same issue! I got u created an issue in the issue tracker for the Hibernate-Team. Could u share me the link so that I can follow when the bug will be fixed? Thanks in advance.