[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5024) MetadataContext#registerAttribute does not recognize inherited fields
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Thu Jan 19 12:52:10 EST 2012
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45179#comment-45179 ]
Hardy Ferentschik commented on HHH-5024:
----------------------------------------
I was looking at the tests _org.hibernate.ejb.test.metagen.mappedsuperclass.idclass.MappedSuperclassWithEntityWithIdClassTest_ and _org.hibernate.ejb.test.metagen.mappedsuperclass.embeddedid.MappedSuperclassWithEmbeddedIdTest_ and there is problem with the metamodel getting populated, but where do you think the actual static classes are wrong?
In _MappedSuperclassWithEntityWithIdClassTest_ we have the above mentioned _AbtractProduct_, _Product_ and _ProductId_ which result in:
{code:title=AbstractProduct_.java|borderStyle=solid}
package org.hibernate.ejb.test.metagen.mappedsuperclass.embeddedid;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(AbstractProduct.class)
public abstract class AbstractProduct_ {
public static volatile SingularAttribute<AbstractProduct, ProductId> id;
}
{code}
{code:title=Product_.java|borderStyle=solid}
package org.hibernate.ejb.test.metagen.mappedsuperclass.embeddedid;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(Product.class)
public abstract class Product_ extends org.hibernate.ejb.test.metagen.mappedsuperclass.embeddedid.AbstractProduct_ {
public static volatile SingularAttribute<Product, String> description;
}
{code}
and
{code:title=ProductId_.java|borderStyle=solid}
package org.hibernate.ejb.test.metagen.mappedsuperclass.embeddedid;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(ProductId.class)
public abstract class ProductId_ {
public static volatile SingularAttribute<ProductId, Integer> id;
public static volatile SingularAttribute<ProductId, String> code;
}
{code}
Just trying to find out whether this is a problem with the generated classes.
> MetadataContext#registerAttribute does not recognize inherited fields
> ---------------------------------------------------------------------
>
> Key: HHH-5024
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5024
> Project: Hibernate ORM
> Issue Type: Bug
> Components: entity-manager, metamodel
> Affects Versions: 3.5.0-CR-2, 3.5.1, 4.0.0.Final
> Environment: Hibernate 3.5.0-CR-2, JPA Modelgen 1.0.0-CR-1
> Reporter: Adrian Hummel
> Assignee: Steve Ebersole
> Fix For: 4.1.0
>
> Attachments: bugreport.zip, hhh-5024.zip, hhh-5024.zip
>
> Time Spent: 6.85h
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list