I have a @OneToMany using a @CollectionOfElements
to an Enum.
@CollectionOfElements
@JoinColumn(name="preference_fk")
public List<ExcludedType> getExcludedTypes()
{
return this.excludedTypes;
}
Using Hibernate Tools to generate the DDL from the annotations works fine, I get a child table with something like :-
Excluded_Types table
preference_fk long
elt long
where parent_fk is the foreign to the parent table, and elt the ordinal representing the enum's numeric value.
However, because we need to use DBUnit to load/prepare some integration test data for the whole DB, dbunit prefers every table having a Primary Key defined - it then allows updates to be made.
I can force a unique key using something like (haven't got the src handy right now) :-
uniqueConstraints = {@UniqueConstraint(columnNames={"preference_fk", "elt"})}
but DBUnit looks for a Primary Key not a unique key.
1) Is there anyway I can generate a compound Primary key of (preference_fk, elt) from the annotations ?
many thanks
|