Hi,

The PostPersist method does have access to the generated id value. But
the id value is generated when a new record is inserted into the
table. It is not guaranteed that the PostPersist method will be called
immediately after an em.persist() call. The spec says,

"The PostPersist and PostRemove methods will be invoked after the
database insert and delete operations respectively."

These insert and delete operations may themselves happen only at
em.flush() or em.commit() time. At that time, the id value is
generated and the PostPersist method is called.

Thanks,
Dinkar

Reply via email to