-->
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.  [ 2 posts ] 
Author Message
 Post subject: Multiple unique-key constraints on a single column
PostPosted: Mon Sep 27, 2010 6:47 pm 
Newbie

Joined: Mon Sep 27, 2010 6:27 pm
Posts: 1
Is it possible to map multiple unique-key constraints where one of the column is shared by 2 or more constraints?

For example a table with:

columnA
columnB
columnC

Where there is a unique constraint "Unique_A_B" on columns "columnA" and "columnB" and another unique constraint "Unique_A_C" on columns "columnA" and "columnC". How can we map this in hibernate mapping file?


Top
 Profile  
 
 Post subject: Re: Multiple unique-key constraints on a single column
PostPosted: Tue Sep 28, 2010 12:55 pm 
Newbie

Joined: Fri Feb 27, 2009 8:02 am
Posts: 10
Location: Woking, England
Hi,
I haven't solved your problem, and apologies in advance if you know this already - but in case it helps.

The annotations for the unique keys work for me as follows:-
Code:
@Table(name = "STUFF", uniqueConstraints = {
      @UniqueConstraint(name = "Unique_A_B", columnNames = { "COL_A", "COL_B" }),
      @UniqueConstraint(name = "Unique_B_C", columnNames = { "COL_B", "COL_C" }) })


I have run the hibernate tool <hbm2hbmxml/> on this annotated file but the generated stuff.hbm.xml file did not define the constraints.

Again, sorry if this was obvious to you, but I thought it might help in some way. Martin.

_________________
Thanks in advance for any helpful replies :O)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.