-
1. Re: Can I audit only a foreign key and not the reffered entity?
hernanbolido Nov 14, 2010 9:37 PM (in response to florin13)Hi!
You can audit the relation from Person to Name whitout auditing Name entity marking that relation as @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED).
Note that:
- The history instances of Person are going to reference the current instance of Name.
- If the relation changes, the related Name changes, but there is not historic instance of Name.
- If you delete a Name and it's referenced by an historic instance, it will fail.
Hope it will help.
Regards. Hernán.
-
2. Re: Can I audit only a foreign key and not the reffered entity?
florin13 Nov 11, 2010 9:41 PM (in response to hernanbolido)Is there any way in which I can audit the actual foreign keys that existed when the history entries were created? I mean, can I have any history instance of Person reference the instance of Name that existed at the moment of its creation?
Having all the Person histories reference the current instance of name is of no use to me.
-
3. Re: Can I audit only a foreign key and not the reffered entity?
florin13 Nov 11, 2010 10:24 PM (in response to florin13)This is how I would like the Person and Person_AUD tables to look like.
Before:
Person: Id=3, Name_Id=234
Person_AUD: Id=3, REV=1, REVTYPE=0, Name_Id=234
After (changing the name):
Person: Id=3, Name_Id=345
Person_AUD:Id=3, REV=1, REVTYPE=0, Name_Id=234
Id=3, REV=2, REVTYPE=1, Name_Id=345
-
4. Re: Can I audit only a foreign key and not the reffered entity?
adamw Nov 12, 2010 5:07 AM (in response to florin13)That's what you will have if you use @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED).
This will work as expected as long as the Name entity is immutable (that is, a name never changes, but a reference from a Person to a Name can change).
Adam