additional error handling when clear(EMF) is called

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1022157 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-10-13 15:56:51 +00:00
parent 0c239c2dc4
commit f3e45e5e54
1 changed files with 17 additions and 9 deletions

View File

@ -313,6 +313,7 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
return; return;
} }
EntityManager em = emf.createEntityManager(); EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin(); em.getTransaction().begin();
for (ClassMetaData meta : types) { for (ClassMetaData meta : types) {
if (!meta.isMapped() || meta.isEmbeddedOnly() if (!meta.isMapped() || meta.isEmbeddedOnly()
@ -323,8 +324,15 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
em.createQuery("DELETE FROM " + meta.getTypeAlias() + " o").executeUpdate(); em.createQuery("DELETE FROM " + meta.getTypeAlias() + " o").executeUpdate();
} }
em.getTransaction().commit(); em.getTransaction().commit();
} catch (Exception e) {
// ignore
} finally {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close(); em.close();
} }
}
/** /**
* Return the entity name for the given type. * Return the entity name for the given type.