Question

Hypothetical scenario: I have two models: Author and Book. The Book model has a many-to-one relationship for Author.

Let's say that I only want to audit changes to Book. I annotate the class with @Audited, but get an error complaining that the getAuthor() property of Book can not be audited since Author is not audited.

Why is this? I want to audit if the author of the book changes, but I don't care if the authors nickname changes. It doesn't make sense for to have an author_aud table in my database, but apparently this is not possible unless I go ahead and audit the Author model OR specifically annotate the getAuthor() property with an @Audited(...) with a property to ignore the relationship. However, if I do this I will no longer be able to audit the book/author relationship.

Was it helpful?

Solution

You will probably not be able to audit the book and it's author relationship if the author is not audited. Maybe you should change the way the relation is mapped : it's strange to have a book "own" it's author : I would have done an unidirectionnal manyToOne relationship from author to its books. With this conception, you will be able to audit the books without auditing the authors.

OTHER TIPS

Add this mapping to the ManyToOne relation.

@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top