[jbpm-commits] JBoss JBPM SVN: r2227 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/db.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Sep 13 10:57:51 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-09-13 10:57:51 -0400 (Sat, 13 Sep 2008)
New Revision: 2227

Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
Log:
More on createSchema in setUp

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2008-09-13 13:25:38 UTC (rev 2226)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2008-09-13 14:57:51 UTC (rev 2227)
@@ -30,6 +30,7 @@
 import org.hibernate.tool.hbm2ddl.SchemaExport;
 import org.jbpm.AbstractJbpmTestCase;
 import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmConfigurationTestHelper;
 import org.jbpm.JbpmContext;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
@@ -40,7 +41,6 @@
 
 public abstract class AbstractDbTestCase extends AbstractJbpmTestCase
 {
-
   private JbpmConfiguration jbpmConfiguration;
 
   protected JbpmContext jbpmContext;
@@ -59,9 +59,24 @@
   {
     log.debug("### starting " + getLongName() + " ####################################################");
     super.setUp();
-    createSchema();
-    createJbpmContext();
-    initializeMembers();
+
+    // Note, that is setUp fails a call to tearDown will not happen.
+    try
+    {
+      // TODO: This creates the schema on EVERY test
+      createSchema();
+
+      // If a clean DB is realy needed this should perhaps be done
+      //cleanSchema();
+
+      createJbpmContext();
+      initializeMembers();
+    }
+    catch (Exception ex)
+    {
+      ex.printStackTrace();
+      throw ex;
+    }
   }
 
   public void tearDown() throws Exception

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2008-09-13 13:25:38 UTC (rev 2226)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2008-09-13 14:57:51 UTC (rev 2227)
@@ -115,6 +115,9 @@
   {
     if (cleanSql == null)
     {
+      String catalog = properties.getProperty(Environment.DEFAULT_CATALOG);
+      String schema = properties.getProperty(Environment.DEFAULT_SCHEMA);
+
       // loop over all foreign key constraints
       List dropForeignKeysSql = new ArrayList();
       List createForeignKeysSql = new ArrayList();
@@ -128,16 +131,26 @@
           while (subIter.hasNext())
           {
             ForeignKey fk = (ForeignKey)subIter.next();
-            //if (fk.getReferencedTable() != null && fk.isPhysicalConstraint())
-            if (fk.isPhysicalConstraint())
+
+            // Prevent NPE in ForeignKey.isPhysicalConstraint
+            // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3479
+            if (fk.getReferencedTable() != null)
             {
-              // collect the drop foreign key constraint sql
-              dropForeignKeysSql
-                  .add(fk.sqlDropString(dialect, properties.getProperty(Environment.DEFAULT_CATALOG), properties.getProperty(Environment.DEFAULT_SCHEMA)));
-              // and collect the create foreign key constraint sql
-              createForeignKeysSql.add(fk.sqlCreateString(dialect, mapping, properties.getProperty(Environment.DEFAULT_CATALOG), properties
-                  .getProperty(Environment.DEFAULT_SCHEMA)));
+              if (fk.isPhysicalConstraint())
+              {
+                // collect the drop foreign key constraint sql
+                String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
+                dropForeignKeysSql.add(sqlDropString);
+
+                // and collect the create foreign key constraint sql
+                String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
+                createForeignKeysSql.add(sqlCreateString);
+              }
             }
+            else
+            {
+              System.out.println("NoReferencedTable: " + fk);
+            }
           }
         }
       }




More information about the jbpm-commits mailing list