• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto increment key in Hibernate

 
kala praveen
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?


Thank you,
Kala.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Mark
 
kala praveen
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mark. It got resolved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic