Simply I want to clear the peristence contexte of my entity manager to reload ALL data from database and specially in that method:
public MyEntity find(Object id) {
EntityManager em = getEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.flush();
tx.commit();
em.clear();
return em.find(MyEntity .class, id);
}
But it seems that flush()
is not working properly because when I insert an OtherEntity
and execute that method I don't find it in the persistence context by getCollection()
method (only after restarting my app)..