Author: amita
Date: Thu Nov 29 02:55:58 2007
New Revision: 599374

URL: http://svn.apache.org/viewvc?rev=599374&view=rev
Log:
TUSCANY-1922 correction for drop tables sequence

Modified:
    
incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
    incubator/tuscany/java/das/samples/dbconfig/src/test/resources/dbConfig.xml

Modified: 
incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java?rev=599374&r1=599373&r2=599374&view=diff
==============================================================================
--- 
incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
 (original)
+++ 
incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
 Thu Nov 29 02:55:58 2007
@@ -157,9 +157,9 @@
             dbStatement = dbConnection.createStatement();
 
             if (dbConnection != null && dbStatement != null && 
dbConfig.getTable() != null && dbConfig.getTable().size() > 0) {
-                Iterator tableIterator = dbConfig.getTable().iterator();
-                while (tableIterator.hasNext()) {
-                    Table table = (Table) tableIterator.next();
+               //reverse order to take care of dropping child tables before 
parent tables.
+               for(int i=dbConfig.getTable().size()-1; i>-1; i--) {
+                       Table table = (Table) dbConfig.getTable().get(i);
 
                     if (table.getSQLCreate() != null && 
table.getSQLCreate().length() > 0) {
                         if (logger.isDebugEnabled()) {
@@ -174,8 +174,8 @@
                                 this.logger.log(Level.DEBUG, "Error droping 
table '" + table.getName() + "'", e);
                             }
                         }
-                    }
-                }
+                    }                          
+               }
             }
         } catch (SQLException e) {
             if (logger.isDebugEnabled()) {

Modified: 
incubator/tuscany/java/das/samples/dbconfig/src/test/resources/dbConfig.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dbconfig/src/test/resources/dbConfig.xml?rev=599374&r1=599373&r2=599374&view=diff
==============================================================================
--- incubator/tuscany/java/das/samples/dbconfig/src/test/resources/dbConfig.xml 
(original)
+++ incubator/tuscany/java/das/samples/dbconfig/src/test/resources/dbConfig.xml 
Thu Nov 29 02:55:58 2007
@@ -44,4 +44,9 @@
                <row>'Jane Doe','E0003',0,12</row>
                <row>'Al Smith','E0004',1,12</row>
        </Table>
+       <Table name="STATES" SQLCreate="CREATE TABLE STATES (ID INT PRIMARY KEY 
NOT NULL, NAME VARCHAR(2))">
+       </Table>
+       <Table name="CITIES" SQLCreate="CREATE TABLE CITIES (ID INT PRIMARY KEY 
NOT NULL, NAME VARCHAR(50), STATES_ID INTEGER,  
+       CONSTRAINT FK1 FOREIGN KEY (STATES_ID) REFERENCES  STATES (ID) ON 
DELETE NO ACTION ON UPDATE NO ACTION)"        >
+       </Table>        
 </DBConfig>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to