Home » Support » Forum » Newbie : How to return the auto-generated ID

Newbie : How to return the auto-generated ID

#1

Hello,

I am new to this community, as well as JPA and ObjectDB. I want to read the auto-generated ID when I persist a new entity (with @Id @GeneratedValue annotations applied). I am following the following link : http://www.objectdb.com/tutorial/jpa/eclipse/web/entity

Thanks.

#2

The id is available in the id field so you can simply access it.

By default, however, the allocated value is available only after commit or flush and not after persist.

If you need to have the id available earlier (immediately after persist) - you have to switch to sequence or table value generation strategy.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login