Hibernate envers not detecting add/remove operations within an association

Hello,
I’m using Hibernate 5.1.17 as ORM and Hibernate-envers to implement the audit layer.
I have encountered a blocking issue for many days that prevent me to progress.
Hibernate-envers is unable to detect changes in collection(add/remove elements from/to Set) which is equivalent to an association table in the database entiteled ACTIVITIES_RELATIONS.

Here are my classes:

class Activity{
....
@Id
private Long id;

@ManytoMany
private Set<Relation> relations;
}

//getters and setters
public class Relation {

@Id
private Long id;

//getters and setters + other attributes
}

When I checked the database I found that the audit table is well created and every modification in the association is tracked (knowing that Relation objects are not created in the same transaction in which the Activity was created) . However, I’m always getting empty Relation Set when I’m trying to get the modifications at specific revision number.

Finally that’s how I’m fetching modifcations of Activity object:

Activity activity = auditReader.find(Activity.class, 6l, 58);

Many Thanks,

Did you try updating to the latest Hibernate version yet? Chances are, you might be running into a bug that has already been fixed. Please report back if the latest version works and also what SQL queries are executed.

Unfortunately, I upgraded Hibernate to the following version 5.6.1.Final but it still not working.
I’m always getting empty Relations Set !

In that case, please provide a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

According to the user guide of Hibernate 5 ,the main limitation of the current queries implementation is that you cannot traverse relations.

I think that was recently fixed for Hibernate 6.0, so maybe give the next 6.0 Beta a shot.