This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes how can I check duplicate record value in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how can I check duplicate record value in hibernate" Watch "how can I check duplicate record value in hibernate" New topic
Author

how can I check duplicate record value in hibernate

sarita chaudhary
Ranch Hand

Joined: Aug 19, 2013
Posts: 39
Hi all,
Hi I am new to hibernate and struts2 and I have created the project whiich contains user registration page , in which the fields are firstnaem,middlename,lastname and emailid.Now in this I have to check that
emailid should be unique for each user so no duplicates can be provided.
Can anyone tell how can I check this through database in hibernate .
manish ghildiyal
Ranch Hand

Joined: Jan 12, 2013
Posts: 136
Am also a novice in database, but I guess you can try to fetch data for the given
email-id by writing a HSQL query....if no data is fetched then it means id is unique.

Manish
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

Hey Sarita,

I agree with Manish, If you are trying validate that email id entered by new user does not already exist in database, you shall have to make a DB call. You can fire the query to get the number of rows in the table having same email id, as passed by the new user, if the result is zero the email id has not already been used.

You can use various ways like Criteria, HQL, Detached Criteria, named query or native query to implement the query.


Regards
Salil Verma
 
Have you checked out Aspose?
 
subject: how can I check duplicate record value in hibernate
 
jQuery in Action, 3rd edition