Hello,
I have a stateless session bean with code snippets below.
@PersistenceContext
private EntityManager em;
...
public void setList(ContainerList list, int key) {
ContainerList stored = (ContainerList)em.find(ContainerList.class, key);
list.setId(key);
if (stored == null) { em.persist(list); }
else {
em.merge(list); // 1st alternative
// stored.copy(list); // 2nd alternative
}
}
...
When I call the method setList for a non existing key, the entity is stored in the database. When I call the method for an existing key, the old value is not updated by the new, i.e. the merge method has no effect. If I comment out the 2nd alternative, it has no effect either. Does anyone has an idea why this does not work? I am using Netbeans 5.5 and 5.5.1 release candidate 1. (With the included application server.)