|
In the following situation, the mapkeycolumn is not honored and the resulting schema contains 'garbage':
@MapKeyColumn(name="ELEMENT__KEY")
@MapKeyEnumerated(EnumType.STRING)
@ElementCollection
@CollectionTable(
name="PCY_JT_MAP_ENTITY_ENUM_RECS",
joinColumns={@JoinColumn(name="PARENT__ID")}
)
@AttributeOverrides({
@AttributeOverride(name="value.name", column=@Column(name="R_NAME")),
@AttributeOverride(name="value.value", column=@Column(name="R_VALUE"))
})
private Map<Color,Record> enumRecs = new HashMap<Color,Record>();
Creates the following table:
create table PCY_JT_MAP_ENTITY_ENUM_RECS (PARENT__ID binary not null, R_NAME varchar(255), R_VALUE integer, primary key (PARENT__ID))
One can see, that the mapkeycolumn is completely missing. Color is an enumeration type and Record is a simple embeddable with two fields. Even worse is the following:
@MapKeyColumn(name="ELEMENT__KEY")
@ElementCollection
@CollectionTable(
name="PCY_JT_MAP_ENTITY_STRING_RECS",
joinColumns={@JoinColumn(name="PARENT__ID")}
)
@AttributeOverrides({
@AttributeOverride(name="value.sup", column=@Column(name="VSUP")),
@AttributeOverride(name="value.r.name", column=@Column(name="R_NAME")),
@AttributeOverride(name="value.r.value", column=@Column(name="R_VALUE"))
})
private Map<String,SuperRecord> stringRecs = new HashMap<String,SuperRecord>();
This produces the following table:
create table PCY_JT_MAP_ENTITY_STRING_RECS (PARENT__ID binary not null, R_NAME varchar(255), R_VALUE integer, VSUP varchar(255), count integer not null, hash integer not null, offset integer not null, value varchar(255), primary key (PARENT__ID, count, hash, offset, value))
This time, the specified mapkeycolumn is also missing, but a bunch of attributes (count,hash,offet,value) magically appear to make up the primary key ???? In this case SuperRecord is an embeddable with an attribute named 'sup' and an attribute 'r' which contains a Record as in the first case (having two fields 'name' and 'value'.
|