-->
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: Want to avoid duplicate values for perticular column
PostPosted: Wed Sep 10, 2008 5:34 am 
Newbie

Joined: Fri May 02, 2008 1:25 am
Posts: 7
How can I mapp the property when I want to avoid the duplication of perticular property which is not primary key of the data base.

For example I have one pojo class called LoginPojo

it has following fields

Integer userId
String userName
String userRole
String userPassword

The primary key of the login table is USER_ID which is mapped with the userId field. But I want the userName should not duplicate means two user can't have the same userName.

Is there any way to avoid this at the time of mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 6:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Use the unique="true" attribute:
Code:
<property  .... unique="true" />


Note that this only affects the schema generation tool that will create an appropriate constraint on the database column.


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.