-->
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: @CollectionOfElements and Primary Key needed
PostPosted: Sat May 13, 2006 6:05 pm 
Newbie

Joined: Tue May 02, 2006 12:32 pm
Posts: 8
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


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.