[hibernate-issues] [Hibernate-JIRA] Assigned: (HHH-6331) Envers @mappedSupperclass bad behaviour

Gail Badner (JIRA) noreply at atlassian.com
Mon Aug 15 20:56:03 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner reassigned HHH-6331:
--------------------------------

    Assignee: Adam Warski

Adam, please assign as appropriate.
Thanks,
Gail

> 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
>            Assignee: Adam Warski
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list