| Author |
Hibernate Unique Statement
|
Abiodun Adisa
Ranch Hand
Joined: Jan 17, 2002
Posts: 495
|
|
I have this entry in my hbm.xml and i use unique=true which is to ensure that values inserted are unique but its not working because i am able to insert same username into database Please how can i resolve this
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
The unique attribute of the property element is used by Hibernate's DDL generation stuff to create the unique index. It does not validate whether the value is unique. It (quite rightly) leaves that to the database. If this constraint is important, why don't you have a unique index defined? If you are looking for this sort of per property rule validation functionality, have a look at Hibernate Validator.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
 |
|
|
subject: Hibernate Unique Statement
|
|
|