-->
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.  [ 5 posts ] 
Author Message
 Post subject: unique multiple keys (not comoposite id)
PostPosted: Mon Oct 20, 2003 8:34 am 
Newbie

Joined: Mon Oct 20, 2003 8:17 am
Posts: 2
I have a class with it's own unique ID that refers to 2 other classes through many-to-one mappings. Is there a way to indicate to hibernate that the values of the 2 mappings when combined should be unique?

As an example, consider the following 3 tables

create table A
(
a_key INT PRIMARY KEY
.....
);

create table B
(
B_key INT PRIMARY KEY
.....
);

create table C
(
C_key INT PRIMARY KEY,
A_key INT NOT NULL,
B_key INT NOT NULL,
CONSTRAINT fka FOREIGN KEY (A_key) REFERENCES A(A_key),
CONSTRAINT fkb FOREIGN KEY (B_key) REFERENCES B(B_key)
);

CREATE UNIQUE INDEX IX_AB ON C(A_key,B_key);

In terms of these tables my question is; In the hibernate config files what do I use to declare the unique index on the values of C(A_key, B_key)?

thanks,
Andy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use the unique-key attribute.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:44 am 
Newbie

Joined: Mon Oct 20, 2003 8:17 am
Posts: 2
Thanks for that. Is there an xdcolet tag for this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
@hibernate.column unique-key="...."


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 7:27 am 
Beginner
Beginner

Joined: Fri Feb 06, 2004 6:59 am
Posts: 36
Location: S
So it whould use the unique-key in the db?

like

@hibernate.column unique-key="IX_AB" ?????

Is that right?

_________________
Best Regards,
Ernani Joppert Pontes Martins


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

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.