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;
}
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
for (ClassMetaData meta : types) {
if (!meta.isMapped() || meta.isEmbeddedOnly()
|| Modifier.isAbstract(meta.getDescribedType().getModifiers())
&& !isBaseManagedInterface(meta, types)) {
continue;
try {
em.getTransaction().begin();
for (ClassMetaData meta : types) {
if (!meta.isMapped() || meta.isEmbeddedOnly()
|| Modifier.isAbstract(meta.getDescribedType().getModifiers())
&& !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();
}
/**