-
1. Re: Auditing the not-owning side of a many-to-one relation
adamw Sep 6, 2011 11:05 AM (in response to sebp)1 of 1 people found this helpfulCurrently not unfortunately. The whole idea is that without the @OneToMany, if you just add or remove a B, the A object is not modified in any way.
But maybe let's step back, why would you want a revision for A created?
Adam
-
2. Re: Auditing the not-owning side of a many-to-one relation
sebp Sep 6, 2011 2:22 PM (in response to adamw)Hi Adam,
thanks for your reply. In real life my entities A and B are in different schemas. A must not know B because B is added through some kind of 'plug-in' functionality. As soon as B is available through the Plug-in, the user must be able to see all revisions of A in a dialog, choose a revision of A and click on a button that opens all Bs that where connected to A at the choosen revision. So the user should be able to do a horizontal audit from A to B.
-
3. Re: Auditing the not-owning side of a many-to-one relation
adamw Sep 8, 2011 7:14 AM (in response to sebp)So when listing revisions of A, you also want to include the revisions where related B's changed, not only A's? As otherwise you can simple do auditReader.getRevisionNumbers(A.class, aID)?
Adam -
4. Re: Auditing the not-owning side of a many-to-one relation
sebp Sep 8, 2011 8:55 AM (in response to adamw)Exactly. The revisions of A where Bs have changed should be shown.
-
5. Re: Auditing the not-owning side of a many-to-one relation
adamw Sep 9, 2011 9:37 AM (in response to sebp)Is be only one entity or are there potentially B1, B2, ..., Bn? If there's one, you could do a query to get all revisions of B's where the related A's id is some given value.
Adam
-
6. Re: Auditing the not-owning side of a many-to-one relation
sebp Sep 20, 2011 9:58 AM (in response to adamw)But the part of the program that wants to display the audit of A does not know B. Therefore it also doesn't know that it must consider B and the versions of A related to B when it displays the audit of A.
I've had a look in the envers 1.2.2 source code and found out that the AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(...) method checks if the relation between A and B is bidirectional. Since it is not, it skips the versioning of A. If I set the bidirectional property of the relation to true in debug mode, then auditing of A works fine. I'm thinking about removing the relDesc.isBidirectional() check. If I do this, will I face any problems? It seems not.