public WorkUnit save(WorkUnit wu) { entityManager.getTransaction().begin(); WorkUnit ret; if (wu.getId() == 0) { entityManager.persist(wu); ret = wu; } else { ret = entityManager.merge(wu); } entityManager.getTransaction().commit(); return ret; }