[hibernate-issues] [Hibernate-JIRA] Commented: (METAGEN-29) Embedded generic types not supported by metamodel generator

Andy Schlaikjer (JIRA) noreply at atlassian.com
Tue Dec 7 13:04:13 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-29?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39308#action_39308 ] 

Andy Schlaikjer commented on METAGEN-29:
----------------------------------------

bq. The generated meta class AbstractEntity_ should use the upper bound of T for the property. In the example SingularAttribute<AbstractEntity, Object>.

I think there's another wrinkle to this bug-- Within {{Person_}}, shouldn't the {{foo}} attribute be redefined to match {{SingularAttribute<Person, String>}} based on {{Person}}'s assignment of {{String}} to {{AbstractEntity}}'s type parameter? Otherwise, in cases where {{foo}} is something more complex, like an Embeddable type, you can't use the generated metamodel to reference components of {{Person_.foo}}. Here's a more complete example:

First, we have an Embeddable value type {{Foo}}:

{noformat}
@Embeddable
public class Foo {
	private String name;
}
{noformat}

Now, a parameterized base class {{Base<T>}}:

{noformat}
@MappedSuperclass
public abstract class Base<T> {
	private T value;
}
{noformat}

And a refinement of {{Base<T>}}, specifying {{Foo}} as its type parameter:

{noformat}
@Embeddable
public class Fooed extends Base<Foo> {
}
{noformat}

Now, what should our metamodel types be? {{Foo}} is straight-forward:

{noformat}
@StaticMetamodel(Foo.class)
public abstract class Foo_ {
	public static volatile SingularAttribute<Foo, String> name;
}
{noformat}

{{Base_}} would look something like this:

{noformat}
@StaticMetamodel(Base.class)
public abstract class Base_ {
	public static volatile SingularAttribute<Base, Object> value;
}
{noformat}

and {{Fooed_}} might look like this:

{noformat}
@StaticMetamodel(Fooed.class)
public abstract class Fooed_ extends Base_ {
	public static volatile SingularAttribute<Fooed, Foo> value;
}
{noformat}

With {{hibernate-jpamodelgen 1.1.1.Final}}, {{Fooed_}} doesn't get a new definition for {{value}}, which, as far as I can tell, prevents us from creating criteria paths from {{Fooed_.value}} to {{Foo_.name}}.

> Embedded generic types not supported by metamodel generator
> -----------------------------------------------------------
>
>                 Key: METAGEN-29
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-29
>             Project: Hibernate Metamodel Generator
>          Issue Type: Bug
>          Components: processor
>    Affects Versions: 1.0.0-CR-1
>         Environment: Hibernate 3.5.0-CR-2
>            Reporter: Adrian Hummel
>            Priority: Critical
>             Fix For: 1.1.0.CR1
>
>         Attachments: bugreport.zip
>
>
> Scenario: I have a @MappedSuperclass defining an abstract entity. This class has a technical primary key and a business identity. The business identity is realized by means of a generic embeddable (e.g. for a Customer class there is a corresponding CustomerId class for its business identity).
> The JPAMetaModelEntityProcessor does generate the AbstractEntity_ class but does only include the primary key field but omits the generic field for the business identity (which leads to subsequent errors when accessing this field using a CriteriaBuilder).
> Attached a mini project with a test case which illustrates the problem. 

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