Overrides a layered entity

The user has n contacts. A contact may have a localized comment (comments are shared between contacts). Java Beans:

@Audited @Entity public class User { @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) Set<Context> contacts; } @Audited @Entity public class Contact { @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) Comment comment; } @Audited @Entity public class Comment { String de; String en; String fr; } 

If I changed the German localization (Comment.de) of the contact (Contact.comment), then this will create a new revision, but not for the user. If I ask envers for User Revisions, I will never see this “level 2 change”, because the connection between the user and the contact has not changed, only the German line in the comment for the contact has been changed.

But I want to see a new entry in the User History (Changed German comment for XYZ contact).

How can I do this ?: D

thanks

+5
source share
1 answer

Perhaps the idea would be to use your own change log (http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch15.html#envers-revisionlog), in which you store the "root "the object / entities for which this change matters. This may not be the most efficient, but depending on your domain model, this may be what you want.

+1
source

Source: https://habr.com/ru/post/1393349/


All Articles