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.