entityManager.getTransaction().rollback() detaches entities?
问题 I have the following piece of code: EntityManagerFactory emf = Persistence.createEntityManagerFactory("test") EntityManager entityManager = emf.createEntityManager() User user = entityManager.find(User.class, 0); entityManager.getTransaction().begin(); entityManager.getTransaction().rollback(); entityManager.refresh(user); This throws an IllegalArgumentException on the fourth line saying "Entity not managed". If I change the third line to .commit() instead of .rollback() , everything seems to