File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
Greenhorn

Joined: Aug 19, 2013
Posts: 24
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: 253

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
 
wood burning stoves
 
subject: how can I check duplicate record value in hibernate
 
Similar Threads
Estimate length of hibernate query
Servlet Jar Includes in Eclipse
javascript with struts and jsp..
duplicate row for editing
EntityExistsException how to know which key i duplicate?