How do i get a primary key generated for the table created to represent a set.
I have a 'parent' class (A) which contains a Set<C>. The xdoclet tags for the set (S) in A indicates that the associated table is to be named 's' and that A's id is mapped to a column named 'set_id'.
The problem is that the 'primary key' for the generated table (s) should be (set_id, name) and i can't figure out how to generate the table ddl with this primary key. I can't use a composite key class with a Set since the content of the Set (i.e., the composite-element C) doesn't contain both elements of the key.
Thanks, in advance, for any suggestions.
I have a classes like (i have omitted setters for brevity)
class A {
private int id;
private Set S;
/**
* @hibernate.id type="int"
*/
public int getId() {return id;}
/**
* @hibernate.set name="S" table="s" lazy="false" cascade="all"
* @hibernate.collection-key column="set_id"
* @hibernate.collection-composite-element class="C"
*/
public Collection getS() { return S; }
}
where S is a collection (set) of C:
class C {
private String name;
private String value;
/** @hibernate.property name="name" column="name" type="string" length="32" not-null="false" unique="false" */
public String getName() { return name; }
/** @hibernate.property name="value" column="value" type="string" length="32" not-null="false" unique="false" */
public String getValue( { return value; }
}
|