If one has a regular Foo entity and call persist(foo) the @Id is automatically set on the entity. However, if the said Foo entity has a collection of Bars bound to it via
(...)
@OneToMany(cascade=Cascade.ALL)
Set<Bar> getBars()
(...)
and such instance is already persisted, if one creates a new Bar and add it to the Bars collection of foo and calls merge(foo) the Bar just created is persisted, but its @Id is not updated!
Is there a way to retrieve this id, without making a later call to find(Foo.class, foo.getId())?