[hibernate-dev] Hibernate Envers > link between to auditable entities

Dev Stack devstack74 at gmail.com
Thu Sep 1 06:14:07 EDT 2016


we have in our model entity P (product) and entity O (offer). The two
entities have a link.
one instance of P can have one or many O instances.
an instance O has a reference to only one instance of P.
The link is managed in the O side.

P and O are revisioned by Hibernate Envers.

Two use cases to cover:
1) If P instance is updated (new revision) we want that O keep the link
with the old revision of P.
2) When I update O instance, I will move the reference to the last revision
of O instance.

What we did is, inside O class we added to attributes P.id and P.revision.
So when we load the object P we use these to fields to load manually (O DAO
has reference P DAO).

Is there a better way to do it?
Should we keep the reference of P in O instance as auditable and Envers
will manage?


More information about the hibernate-dev mailing list