[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4646) Inconsistent behavior with Audited and MappedSuperclass annotations

Hernán Chanfreau (JIRA) noreply at atlassian.com
Tue Oct 12 18:55:01 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38709#action_38709 ] 

Hernán Chanfreau commented on HHH-4646:
---------------------------------------

I've been looking at this issue and I realized that the main problem is the way we are reading the audited properties. In AuditedPropertiesReader class we have:

	private void addPropertiesFromClass(XClass clazz)  {
		XClass superclazz = clazz.getSuperclass();
		if (!clazz.isInterface() && !"java.lang.Object".equals(superclazz.getName())) {
			addPropertiesFromClass(superclazz);
		}

		addFromProperties(clazz.getDeclaredProperties("field"), "field", fieldAccessedPersistentProperties);
		addFromProperties(clazz.getDeclaredProperties("property"), "property", propertyAccessedPersistentProperties);
	}

The actual algorithm process recursively superclasses. The concrete class is the last one processed. 

I think we could fix this issue if we check concrete class first and we process superclasses only if the concrete class has audited properties (or is audited at class level).
Do you see any problem with these changes? 

I've already developed a patch and I've run some tests (including both attached tests on 4646 and 5177). 

After completing test cases I'll propose the patch if you agree.

Regars. Hernán

> Inconsistent behavior with Audited and MappedSuperclass annotations
> -------------------------------------------------------------------
>
>                 Key: HHH-4646
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4646
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: envers
>    Affects Versions: 3.3.2, 3.5.0-Beta-2
>         Environment: 1) hibernate 3.5 build from trunk (7 nov 09) 
> 2) hibernate-core-3.3.2ga with envers build from branch envers-hibernate3.3 (7 nov 09)
>            Reporter: Hernán Chanfreau
>            Assignee: Adam Warski
>            Priority: Minor
>         Attachments: mapperSuperclass2TestPatch.txt
>
>
> Suppose B is a subclass of A.
> The subclass B is @Entity and is not audited.
> The superclass A is @MappedSuperclass.
> The differents/inconsistent 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. 
> You can find the original discussion in envers forum: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=164340

-- 
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