mirror of https://github.com/apache/openjpa.git
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:
parent
0c239c2dc4
commit
f3e45e5e54
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue