EntityManager.merge not doing anything EntityManager.merge not doing anything spring spring

EntityManager.merge not doing anything


Try the em.flush() also after the em.merge(). Sometimes the EntityManager just keeps the the changes for updating later.


EntityManager autocommit is false. Please use transaction like below;

EntityManager em = null;EntityTransaction t = null;try {    em = emf.createEntityManager();    t = em.getTransaction();    t.begin();    em.merge(myTestObject);    t.commit();} catch (Exception e) {    t.rollback();    throw new RuntimeException(e.getMessage());}finally{    if(em != null)        em.close();}


I had the very issue and got resolved by changing the scope.

@PersistenceContext(type=PersistenceContextType.EXTENDED)

ref: Manipulating Entities with EntityManager