If an exception occurs in remove(), the transaction is still open when the
finally block is performed.
Check whether the trans is active and roll it back if so, as in the
following:
} finally {
if (em != null) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
-chris
Cil-Gamir
<hannes.visa...@r
mb.co.za> To
[email protected]
04/09/2010 09:23 cc
AM
Subject
Cannot close EntityManager
Please respond to
[email protected]
che.org
Hi
I have this piece of code
EntityManager em = emf.getEntityManager();
try {
em.getTransaction().begin();
em.remove(kycRequestTempDocumentsToDelete);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
I cannot seem to make that em.close call, it tells me that the transaction
is still active.
I use an em-per-request and that's the end of that request, so I would
really like to close it.
The application runs on tomcat and will likely not be restarted in months,
is it ok to leave the em open, this method gets called thousands of times a
day.
Any advice on how to close it ?
--
View this message in context:
http://n2.nabble.com/Cannot-close-EntityManager-tp4875727p4875727.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.