How to find out efficiently the auto-generated id for a new object when using JPA?
Posted
by webstarg
on Stack Overflow
See other posts from Stack Overflow
or by webstarg
Published on 2010-04-21T22:01:43Z
Indexed on
2010/04/21
22:03 UTC
Read the original article
Hit count: 196
Hello,
I have an attribute which is annotated with @Id. The ID is going to be generated automatically when persisting the object. That means that the ID-value is not defined before I persist the object. After persisting it, it has an ID (in the database), but unfortunately the field still remains null as long as I don't reload it from the DB. is there any easy way to find out the generated id? Or better: To configure that it will be written into the field?
Thanks in advance
© Stack Overflow or respective owner