-->
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.  [ 7 posts ] 
Author Message
 Post subject: annotating a class for unique key constraint?
PostPosted: Wed Sep 28, 2005 1:07 pm 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
I studied the hibernate annotations refernece guide and I really wonder if there is a way to annotate a class in such way that a unique key constraint for some fields are generated ? Any hints on this ? Did I miss something?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Column(unique=true)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Hmm
PostPosted: Sun Oct 02, 2005 4:08 am 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
And what if I need a unique key that spans multiple rows ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 02, 2005 6:15 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Did you try searching the documentation for "unique"? It's the first hit, actually.


Top
 Profile  
 
 Post subject: Sorry I did
PostPosted: Sun Oct 02, 2005 8:16 am 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
do you mean the hibernate annotaions docs ? the search pointed me to an example that doesnt tell me anything. I know how to build a unique identifier. But thats not my concern. I have a surrogate key and need to build a unique constraint on some other cols. Excuse me if I#m too blind I don't see it in the docs.
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 02, 2005 9:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Go there:

http://www.hibernate.org/hib_docs/annot ... ml_single/

Hit CTRL+F, type "unique", hit ENTER.

"You can also define unique constraints to the table using the @UniqueConstraint annotation in conjunction with @Table (for a unique constraint bound to a single column, refer to @Column)."


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Sun Oct 02, 2005 10:35 am 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
i knew it must be there. Thanks for your advice.
Thomas


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