The error is a typical one: the passed log does not get managed after calling merge()
. Only the returned instance is managed.
Try the following:
public void meth1() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
utx.begin();
Log newLog = em.merge(log);
newLog.setMessage(String.valueOf(Math.random()));//we make the changes to the managed instance
utx.commit();
}