Reputation: 6292
I have a hibernate code which insert a new role to the table as follows:
Staff staff = new Staff(staffDTO);
Session session = sessionManager.getSession();
session.beginTransaction();
session.save(staff);
session.getTransaction().commit();
Staff is defined as entity.
My question is that how can I get the newly generated row id by the database?
Many thanks.
Upvotes: 0
Views: 262
Reputation: 121998
Hibernate is smart enough :).
After you save the Object in database If you see ,the object have the generated id. Check it.
After save done, just inspect the object and see.
Upvotes: 4