User: schulze
Date: 00/10/11 12:40:42
Modified: src/main/org/jboss/ejb/plugins CMPPersistenceManager.java
Log:
provided the PersistenceManager init() and destroy() methods with transactions, so
that the table creation/deletion commands will affect the database.
Furthermore I replaced the ugly hack for the table detection in the JDBCInitCommand
with a j2ee spec compilant version (should work with all drivers).
Revision Changes Path
1.12 +35 -3 jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java
Index: CMPPersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CMPPersistenceManager.java 2000/10/09 20:15:37 1.11
+++ CMPPersistenceManager.java 2000/10/11 19:40:42 1.12
@@ -21,6 +21,9 @@
import javax.ejb.RemoveException;
import javax.ejb.EJBException;
+import javax.transaction.Transaction;
+import javax.transaction.Status;
+
import org.jboss.ejb.Container;
import org.jboss.ejb.EntityContainer;
import org.jboss.ejb.EntityPersistenceManager;
@@ -37,7 +40,7 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.11 $
+* @version $Revision: 1.12 $
*/
public class CMPPersistenceManager
implements EntityPersistenceManager {
@@ -98,7 +101,21 @@
}
// Initialize the store
- store.init();
+ // if the store performes database operations (ie: table creations) it
+ // will need a transaction to do so
+ con.getTransactionManager ().begin ();
+ try
+ {
+ store.init();
+ con.getTransactionManager ().commit ();
+ }
+ catch (Exception _e)
+ {
+ con.getTransactionManager ().rollback ();
+ store.destroy ();
+ throw _e;
+ }
+
}
public void start()
@@ -112,7 +129,22 @@
}
public void destroy() {
- store.destroy();
+
+ // same as inistalize...
+ // maybe the store needs to drop tables and he
+ // will need a transaction therefor
+ try
+ {
+ con.getTransactionManager ().begin ();
+ store.destroy();
+ if (con.getTransactionManager().getStatus() == Status.STATUS_ACTIVE)
+ con.getTransactionManager ().commit ();
+ else
+ con.getTransactionManager ().rollback ();
+ }
+ catch (Exception _e)
+ {
+ }
}
public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)