EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
MwMleSource persistentMwMleSource = em.find(MwMleSource.class, mwMleSource.getId());
TblMle mleIdOld = persistentMwMleSource.getMleId();
TblMle mleIdNew = mwMleSource.getMleId();
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
mwMleSource.setMleId(mleIdNew);
}
mwMleSource = em.merge(mwMleSource);
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getMwMleSourceCollection().remove(mwMleSource);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getMwMleSourceCollection().add(mwMleSource);
em.merge(mleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();