I’m using HibernateTemplate to access the database in my Spring application.
Is there any way/method in HibernateTemplate which returns the auto-generate id
for my new inserted row? In my case, the auto-generate value is the primary key of my table, which is defined as auto-increment inside the database.
For more info, I use saveOrUpdate() method to insert data.
When you save a object with
saveOrUpdate()the objectsidfield will get updated with the auto generatedidif it was a create operation. So you can simply retrieve theidproperty of the saved object to get the auto generated id.