Two Laptop Bag*
The moose likes Object Relational Mapping and the fly likes  unique=true in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark " unique=true in hibernate" Watch " unique=true in hibernate" New topic
Author

unique=true in hibernate

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
I would like to know more about unique=true in hibernate. Where and how and why to use it. How to use it for many-many, one-many, many-one, one-one Any ideas, resources, links, sample code highly appreciated.


Getting more confused especially with one-one where for example many students can have same address in this scenario STUDENT_ADDRESS column under student table is set to unique in STUDENT.hbm.xml file.
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-one-to-one-1.html

similarly in one-many example where one student can have many phone numbers the phone id kept as unique within set collection of many-many tag.
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-one-to-many-1.html
please advise.thanks in advance.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Please check the use of "many to many" and "unique" Here.
Also the site you're using to learn Hibernate never explains in depth the details of "many to many" usages.
If I were you, I would start learning from the hibernate docs first.


If you are not laughing at yourself, then you just didn't get the joke.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: unique=true in hibernate