hibernate->JPA for authorization rules.
[utils] / test / enterprise / src / main / java / org / wamblee / support / persistence / DatabaseUtils.java
index 1b300433d8bc49ca268dc964d5db902b28e1231f..311d2da3189afcfcf09141b3b52996cc1895140d 100644 (file)
@@ -96,9 +96,6 @@ public class DatabaseUtils {
                 return null;
             }
         });
-        for (String table : tables) {
-
-        }
     }
 
     public void cleanDatabase(ITableFilterSimple aSelection) throws Exception {
@@ -190,25 +187,30 @@ public class DatabaseUtils {
     public void emptyTable(String aTable) throws Exception {
         executeSql("delete from " + aTable);
     }
-
-    public void dropTables() throws Exception {
-        executeOnTables(tables, new TableSetOperation() {
-
-            public void execute(String aTable) throws Exception {
-                dropTable(aTable);
-            }
-        });
+    
+    public void dropTables() throws Exception { 
+        dropTables(tables);
     }
 
     public void dropTables(ITableFilterSimple aTables) throws Exception {
-        executeOnTables(aTables, new TableSetOperation() {
+        final String[] tables = getTableNames(aTables);
+        String[] sortedTables = executeInTransaction(new JdbcUnitOfWork<String[]>() {
 
-            public void execute(String aTable) throws Exception {
-                dropTable(aTable);
+            public String[] execute(Connection aConnection) throws Exception {
+                IDatabaseConnection connection = new DatabaseConnection(
+                    aConnection);
+                ITableFilter filter = new DatabaseSequenceFilter(connection,
+                    tables);
+                IDataSet dataset = new FilteredDataSet(filter, connection
+                    .createDataSet(tables));
+                return dataset.getTableNames();
             }
         });
+        for (int i = sortedTables.length-1; i >= 0; i--) { 
+            dropTable(sortedTables[i]);
+        }
     }
-
+    
     /**
      * @return
      * @throws SQLException