My EntityManager is persisting/committing data to a Postgres database no problem. However, the connections it makes get stuck at 'Idle in transaction'. Here's my code:
public User create(User user) {
if(logger.isDebugEnabled()) {
logger.info("creating user: {}", user);
}
EntityManager entityManager = DbUtil.factory.createEntityManager();
try {
entityManager.getTransaction().begin();
// Persist takes an entity instance, adds it to the context and makes that instance managed (ie future updates
// to the entity will be tracked).
entityManager.persist(user);
entityManager.getTransaction().commit();
}
catch(RuntimeException e) {
throw getDbException(e);
}
finally {
entityManager.close();
}
return user;
}
Any idea why they aren't closing?