In my project, only the root of my object-graph/aggregate has a @Version property. Each time any child entity is modified, the root is locked with OPTIMISTIC_FORCE_INCREMENT to force the version to change. (I am using something similar as described in https://vladmihalcea.com/2016/08/30/how-to-increment-the-parent-entity-version-whenever-a-child-entity-gets-modified-with-jpa-and-hibernate) I do that so that no concurrent modification can happen on the same aggregate (I don't want people modifying 2 different child entities at the same time and bypassing invariants enforced by the root). My problem is when a child entity is modified, a new revision is only created for the child but not for the root. As I treat my aggregate as a whole only accessible through the root, I would like to be able to list all revisions for the whole aggregate by doing something like auditReader.getRevisions(Root.class, id); So would it be possible to force envers to include the root (that has been locked) in the revision along with the children entities that have been modified? The workaround I have found so far is to manually update some dummy property on the root when any child entity is modified. |