[hibernate-dev] Hibernate Envers > link between to auditable entities
crancran at gmail.com
Thu Sep 1 09:55:35 EDT 2016
There are a few ways we can tackle what you want all within the scope of
but some of it highly depends upon details specific to the relationship
Product (P) and Offer (O).
1. What is the collection type used in Product for the related offers?
If this happens to be a List<>, would it be possible to use a Set<>
2. Is there a requirement that Offer should own the relationship with
In other words, is it possible to invert the relationship such that the
collection side is the owner instead?
On 09/01/2016 06:14 AM, Dev Stack wrote:
> 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?
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
More information about the hibernate-dev