Tenho uma entidade com generator. Após persistir uma nova instância e fazer commit, o valor da chava primária continua com null (o entity manager continua aberto após a transação).
Fazendo um merge() consigo obter o valor da chave, porém esta é a forma mais indicada?
Depois de pesquisar bastante acabei achando na documentação do Hibernate como fazer o que preciso
[quote] You can reload an entity instance and it’s collections at any time using the em.refresh() operation. This is useful when database triggers are used to initialize some of the properties of the entity. Note that only the entity instance and its collections are refreshed unless you specify REFRESH as a cascade style of any associations:
em.persist(cat);
em.flush(); // force the SQL insert and triggers to run
em.refresh(cat); //re-read the state (after the trigger executes)