-->
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: generating primary key for set containing composite element
PostPosted: Fri Jul 30, 2004 9:48 am 
Newbie

Joined: Thu Jan 08, 2004 8:53 pm
Posts: 7
Location: massachusetts
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; }
}


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.