-
1. Re: Question about audited super-classes
adamw Nov 30, 2009 2:55 AM (in response to hernanbolido)Hello,
so both B and A are entities, using some inheritance strategy, or B is a @MappedSuperclass?
Either way you're right that it's inconsistent, annotating a class should be the same as annotating all properties.
To prevent users from "accidentally" auditing a subclass, maybe an exception should be thrown. But then, there should be a way to audit only the properties from the superclass, but none from the subclass.
What do you think, what should be the correct behavior? :)
Also, could you create a JIRA bug for that?
Adam -
2. Re: Question about audited super-classes
hernanbolido Nov 30, 2009 8:34 AM (in response to hernanbolido)Hi Adam, thanks for your time.
I tried 2 cases:Superclass A mark as @MappedSuperclass.
Subclass strategy mapping.
About the correct behavior in this case, I think that the NotAuditedException would be the best option...
I m thinking in big hierarchies in which you want to audit only one branch. In this cases you should annotate the complete branch from the leaf to the root for auditing the branch you need. And the non annotated branch/leaf will not be audited.
At the current time in envers, this restriction is not applied; then if you annotates the root at fields/getters level and save an entity from the non audited branch/leaf , you could be auditing it too.
Do you understand my point?
So, if you want to audit a subclass, you must mark it as auditable. Otherwise it is not audited.
What do you think is the best option?
Thanks again. Hernan. -
3. Re: Question about audited super-classes
adamw Dec 1, 2009 2:40 AM (in response to hernanbolido)Yes, I think I agree, as you say, if you want to audit a subclass, it must be marked auditable, but only the properties from superclasses that are either implictly or explicitly annotated as @Audited are audited.
Could you create a JIRA bug for that? :)
Adam -
4. Re: Question about audited super-classes
hernanbolido Dec 1, 2009 11:11 AM (in response to hernanbolido)Hi Adam!
Before creating the jiira issue I re-test all cases. That is, all hierarchy mapping strategies and the @MappedSubclass too.
I did a mistake with the tests before, because the only case that presents this behavior is when there is a @MappedSuperclass in the superclass A.
So, my original explanation only applies to this case.
Hernan. -
5. Re: Question about audited super-classes
adamw Dec 2, 2009 1:01 PM (in response to hernanbolido)So it doesn't work properly with @MappedSuperclass not audited and the subclass not? :)
Adam -
6. Re: Question about audited super-classes
hernanbolido Dec 2, 2009 3:02 PM (in response to hernanbolido)Hi Adam! Sorry about my mistake.
Here is the case. Suppose B is a subclass of A.
The subclass B is @Entity and is not audited.
The superclass A is @MappedSuperclass.
The differents behaviors are:
- If A has @Audited at class level, envers does not generate audit info when saving an instance of B.
- If A has @Audited at field/getter level, envers generates audit info when saving an instance of B.
Thanks again. Hernan. -
7. Re: Question about audited super-classes
adamw Dec 3, 2009 10:19 AM (in response to hernanbolido)That's clearly a bug :) Please report it in JIRA. And thanks for the detailed investigation.
Adam -
8. Re: Question about audited super-classes
hernanbolido Dec 7, 2009 8:38 AM (in response to hernanbolido)Hi!
Reported in JIRA as HHH-4646
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4646
Thanks. Hernan.