I have a problem with retrieving the primary key of an entity object after persisting. My case is:
:- I have an entity object which has the id as the primary key field of type long and the value is auto generated by the database (and with all necessary annotations assigned)
:- After I invoke the EntityManager "em" to persist my entity (e.g. em.persist(entityObj) ), I want to know what was the newly assigned primary key by the database.
So, is there any way to retrieve the newly assigned primary key of the entity, since the EntityManager.persist() method returns nothing (void)?
Any suggestion will be greatly appreciated. Thank you.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3933024#3933024
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3933024