[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6331) Envers @mappedSupperclass bad behaviour
Facundo Mateo (JIRA)
noreply at atlassian.com
Fri Jun 17 09:16:24 EDT 2011
Envers @mappedSupperclass bad behaviour
---------------------------------------
Key: HHH-6331
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6331
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.1
Environment: Hibernate 3.6.1.Final
Oracle 10g
Reporter: Facundo Mateo
Suppose you have:
* Class A marked as @MappedSuperclass, and has field/property marked as @Audited
* Class B extends from A, and is @Entity but doesn't have any @Audited annotation
Envers is not auditting instances of B, when it should audit the properties marked with @Audit in the superclass.
I have been researching at the sources , and it seems to be a bug introduced with the fix for [HHH-4646|http://opensource.atlassian.com/projects/hibernate/browse/HHH-4646]. The problem is in the class org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader :
{code:title=org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader.java|borderStyle=solid}
private void addPropertiesFromClass(XClass clazz) {
Audited allClassAudited = clazz.getAnnotation(Audited.class);
//look in the class
addFromProperties(clazz.getDeclaredProperties("field"), "field", fieldAccessedPersistentProperties, allClassAudited);
addFromProperties(clazz.getDeclaredProperties("property"), "property", propertyAccessedPersistentProperties, allClassAudited);
if(allClassAudited != null || !auditedPropertiesHolder.isEmpty()) {
XClass superclazz = clazz.getSuperclass();
if (!clazz.isInterface() && !"java.lang.Object".equals(superclazz.getName())) {
addPropertiesFromClass(superclazz);
}
}
}
{code}
if you look this line *if(allClassAudited != null || !auditedPropertiesHolder.isEmpty())*: It only looks for @Audited annotation when the child is marked with class level @Audited or if it has some @Audited property/field, but ignores superclass annotations if it the child doesn't have any.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list