I am facing a peculiar problem with Hibernate. I have an application which uses Hibernate and inserts data into database. While inserting a row which is having an auto increment column as primary key into database Hibernate is giving me duplicate integrity constraint exception. Outside the application I may simultaneously insert data into the same table.
My doubt is : Doesn't Hibernate get latest auto generated key from database while inserting data into a table? How to overcome this problem?
It depends on how you set it in the configuration file. Whether you have native or not. And like in Oracle if you use a sequence table, naming the name of the sequence table in the Java file that is mapped to that table.