[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5024) MetadataContext#registerAttribute does not recognize inherited fields

Stephan Bublava (JIRA) noreply at atlassian.com
Thu Jan 27 06:49:05 EST 2011


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

Stephan Bublava commented on HHH-5024:
--------------------------------------

{quote}Is this still an issue using 3.6.0?{quote}

Yes, but I believe the problem is restricted to @Embedded attributes in a @MappedSuperClass.

When MetaDataContext.wrapUp() processes the sub-class it calls MetaDataContext.registerAttributes(), which in turn calls ManagedType.getDeclaredAttributes() on the type passed in. The result contains all embedded attributes of the super-class in addition to the "regular" attributes of the sub-class, which seems wrong and causes a NoSuchFieldException in MetaDataContext.registerAttribute().


> MetadataContext#registerAttribute does not recognize inherited fields
> ---------------------------------------------------------------------
>
>                 Key: HHH-5024
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5024
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager, metamodel
>    Affects Versions: 3.5.0-CR-2, 3.5.1
>         Environment: Hibernate 3.5.0-CR-2, JPA Modelgen 1.0.0-CR-1
>            Reporter: Adrian Hummel
>            Priority: Critical
>         Attachments: bugreport.zip
>
>
> The embeddable class {{CustomerId}} (see attached ZIP) inherits from the base class {{AbstractIdentity}} (annotated with {{@MappedSuperclass}}). The metamodel classes for these two classes are correctly generated:
> {code:title=AbstractIdentity_.java|borderStyle=solid}
> import javax.persistence.metamodel.SingularAttribute;
> import javax.persistence.metamodel.StaticMetamodel;
> @StaticMetamodel(AbstractIdentity.class)
> public abstract class AbstractIdentity_ {
> public static volatile SingularAttribute<AbstractIdentity, String> id;
> }
> {code}
> and
> {code:title=CustomerId_.java|borderStyle=solid}
> import javax.persistence.metamodel.StaticMetamodel;
> @StaticMetamodel(CustomerId.class)
> public abstract class CustomerId_ extends AbstractIdentity_ {
> }
> {code}
> When building the entity manager factory, {{MetadataContext#registerAttribute}} (line 378) tries to resolve the field {{CustomerId_.id}} using {{Class#getDeclaredField}}. This results in a {{NoSuchFieldException}} because the field is declared in the super class {{AbstractIdentity_}}.
> Proposed solution: Since all field declarations in the metamodel are public, the {{Class#getField}} method should be used instead.

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