-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Generics and Embeddable Components
PostPosted: Wed Apr 11, 2007 1:50 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
Here's an interesting challenge for you annotation gurus:

I'm using Hibernate 3 and Annotations. I've got an embedded component that is generic. In the containing class I then use AttributeOverride to change the column mapping. The only problem is Hibernate doesn't know what type the property is. The error I get is:

org.hibernate.AnnotationException: Property MyEmbedded.value has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type

Here's an example (psuedocode, not compiled):

@Embeddable
public class MyEmbedded<T> {
private T value;
public T getValue() {return value;}
public void setValue(T value) {this.value = value}
}

@Entity
public class MyEntity {
private MyEmbedded embedded;
@Embedded
@AttributeOverride (name="value", column=@Column(name="textValue")
public MyEmbedded<String> getEmbedded() { return embedded; }
}

I can't find a way to tell Hibernate what the type is for the embedded "value" property. If the @AttributeOverride annotation allowed the type to be overridden, the above code would probably work. Is there a way to override the type?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.