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,17 +313,25 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
return; return;
} }
EntityManager em = emf.createEntityManager(); EntityManager em = emf.createEntityManager();
em.getTransaction().begin(); try {
for (ClassMetaData meta : types) { em.getTransaction().begin();
if (!meta.isMapped() || meta.isEmbeddedOnly() for (ClassMetaData meta : types) {
|| Modifier.isAbstract(meta.getDescribedType().getModifiers()) if (!meta.isMapped() || meta.isEmbeddedOnly()
&& !isBaseManagedInterface(meta, types)) { || Modifier.isAbstract(meta.getDescribedType().getModifiers())
continue; && !isBaseManagedInterface(meta, types)) {
continue;
}
em.createQuery("DELETE FROM " + meta.getTypeAlias() + " o").executeUpdate();
} }
em.createQuery("DELETE FROM " + meta.getTypeAlias() + " o").executeUpdate(); em.getTransaction().commit();
} catch (Exception e) {
// ignore
} finally {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
} }
em.getTransaction().commit();
em.close();
} }
/** /**