posted 11 years ago
How to prevent duplicate data entry in hibernate while more than one insertion done being simultaneously (by two different processes) that have auto generated primary key?
Our application will insert record to a mysql table with auto generated primary key and using hibernate 3 and MYSQL 5.5.21. But when the same application is running in more than one PC and both trying to insert record in the table simultaneously, I get the exception as below
org.hibernate.util.JDBCExceptionReporter:logExceptions(78) | Duplicate entry 'somevalue' for key 'PRIMARY'.
Kindly help to resolve this issue.