• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with unique and unique-key

 
Suhas Bilaye
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a table called category in the database which has 2 columns. Id(Primary key) and Title (should be unique)

I am trying to specify that this title should be unique. I am using the hbm file for mapping.
Please see the file as below.



whether is specify unique = true or unique-key = true and try to save a category whose title is "Soaps" multiple times
it still gets saved. The id is automatically generated by using an autoincrement option.., how do i force so that the category should not be saved multiple times .. with the same title.

Please advise.

Regards,
Suhas
 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to http://www.coderanch.com/t/218167/Object-Relational-Mapping/java/Hibernate-Unique-Statement
 
Suhas Bilaye
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic