Author: dwoods
Date: Wed Oct 13 15:06:27 2010
New Revision: 1022129
URL: http://svn.apache.org/viewvc?rev=1022129&view=rev
Log:
add notes about EMF must be manually closed. also clear the EMF before closing
it in when using helper method closeEMF().
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java?rev=1022129&r1=1022128&r2=1022129&view=diff
==============================================================================
---
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
(original)
+++
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java
Wed Oct 13 15:06:27 2010
@@ -83,6 +83,7 @@ public abstract class AbstractPersistenc
/**
* Create an entity manager factory. Put {...@link #CLEAR_TABLES} in this
list to tell the test framework to delete all
* table contents before running the tests.
+ * NOTE: Caller must close the returned EMF.
*
* @param props
* list of persistent types used in testing and/or
configuration values in the form
@@ -102,6 +103,7 @@ public abstract class AbstractPersistenc
/**
* Create an entity manager factory for persistence unit <code>pu</code>.
Put {...@link #CLEAR_TABLES} in this list to
* tell the test framework to delete all table contents before running the
tests.
+ * NOTE: Caller must close the returned EMF.
*
* @param props
* list of persistent types used in testing and/or
configuration values in the form
@@ -123,6 +125,7 @@ public abstract class AbstractPersistenc
/**
* Create an entity manager factory for persistence unit <code>pu</code>.
Put {...@link #CLEAR_TABLES} in this list to
* tell the test framework to delete all table contents before running the
tests.
+ * NOTE: Caller must close the returned EMF.
*
* @param props
* list of persistent types used in testing and/or
configuration values in the form
@@ -219,16 +222,20 @@ public abstract class AbstractPersistenc
* Safely close the given factory.
*/
protected boolean closeEMF(EntityManagerFactory emf) {
+ boolean brc = false;
if (emf == null || !emf.isOpen()) {
- return false;
+ return brc;
}
-
try {
- closeAllOpenEMs(emf);
+ // clear() will also close the EMs
+ // closeAllOpenEMs(emf);
+ clear(emf);
} finally {
emf.close();
- return !emf.isOpen();
+ brc = !emf.isOpen();
+ emf = null;
}
+ return brc;
}
/**