I ran into a strange issue while using JPA (with EclipseLink 4.2.1).
The relevant part of the code:
l.debug("creating EM");
em = factory.createEntityManager();
int id = Integer.parseInt(idString);
l.debug("parsed");
em.getTransaction().begin();
SomeClass g = em.find(SomeClass.class, id);
l.debug("found");
em.remove(g);
l.debug("removed");
em.getTransaction().commit();
l.debug("Returning...");
The output is:
DEBUG - creating EM
DEBUG - parsed
DEBUG - found
DEBUG - removed
As you can see, the last row is not displayed (commit() did not return). It doesn’t throw any exceptions. However, the object is removed from the database.
There is no such problem at any other point in the application.
Usually the root cause of hanging transactions can be a deadlock with other concurent transactions