Hi,
I made a small test using merge and I noticed that after the merge of a transient object the Id of this one is not updated with the generated id.
The insert in the db is successfull.
Here is my test:
Code:
public void testPersistEJB() {
EntityManagerFactory emf = (EntityManagerFactory) context.getBean("entityManagerFactory");
EntityManager em = emf.createEntityManager();
EntityTransaction tx=em.getTransaction();
tx.begin();
Contact contact = new Contact();
contact.setName("Dupondt");
em.merge(contact);
tx.commit();
em.close();
emf.close();
assertNotNull(contact.getId());
}
My Contact class extends a PersistentObject which contains the id definition:
Code:
@Id @GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
private String id;
A workaround could be to check my self if I have to do a merge or persist, but regarding wiht chap 3.7 of the Hibernate EntityManager, the merge should be deal with it and react as a persist. Isn't it?
Now, I wonder, if I missunderstoud the merge functionality or the merge has really a problem?
Regards
Dominique