-->
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.  [ 3 posts ] 
Author Message
 Post subject: Embeddable Objects containing CollectionOfElements
PostPosted: Wed Jan 18, 2006 1:23 pm 
Newbie

Joined: Wed Jan 18, 2006 12:57 pm
Posts: 1
Hibernate version: 3.1

Hibernate annotations version: 3.1 beta 7

I have some embeddable objects that extend the following class (setters removed for clarity). Each extended class sets the type of the value field. One such class is StringValue, so the value property becomes type String. This bit works fine i.e. Database table created with the correct field.

Here's the class:

Code:
@EmbeddableSuperclass
public class BaseTypeValue<T> implements BaseTypeValueI<T> {

   private List<MapEntryImpl> values = new LinkedList<MapEntryImpl>();

   private T value;

   @Basic
   public T getValue() {
      return value;
   }

   @CollectionOfElements
   @IndexColumn(name = "valueMapIndex")
   public List<MapEntryImpl> getValues() {
      return values;
   }
}


However, there is a problem with the values bit, which is a CollectionOfElements. It's essentially a list of Map.Entry objects, but it's my own MapEntry object that implements the Map.Entry interface (I'm getting around the problem that Map has not been implemented fully yet).

The problem is that I have more than one of each of these embeddables in my entities. Hibernate creates my entity table correctly, but then I am expecting it to create a "values" table for each one of the properties on that entity that is one of these embeddables. It only creates one values table. Here's an example Entity (properties and setters removed):

Code:
@Entity
public class Structure {

   @Embedded
   @AttributeOverrides( {
         @AttributeOverride(name = "value", column = @Column(name = "cashValue")) })
   public StringValue getCash() {
      return this.cash;
   }

   @Embedded
   @AttributeOverrides( {
         @AttributeOverride(name = "value", column = @Column(name = "giltsValue")) })
   public StringValue getGilts() {
      return this.gilts;
   }
}



So for this Entity I'd have a table "structure" and one called "structure_values" created. The problem is is that it now needs to use the same values table for the collectionofelements property (values) for each of the StringValue objects in my Structure entity. It should have created two "structure_values" tables, but obviously with different names.

I cannot find a way to get hibernate to create a second (and third, forth etc) table for each StringValue object I have in my entities.

Can someone help me out?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 7:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@JoinTable

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 3:02 am 
Beginner
Beginner

Joined: Wed Oct 08, 2003 6:34 am
Posts: 29
Has anybody been able to solve this?

I've tried to use JoinTable, but this annotation seems only to have some effect if I use it in a CollectionOfElements, not in a Embedded attribute.

TIA, best regards
Jose


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

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.