db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r349139 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils: Platform.java platform/PlatformImplBase.java
Date Sat, 26 Nov 2005 19:48:28 GMT
Author: tomdz
Date: Sat Nov 26 11:48:23 2005
New Revision: 349139

URL: http://svn.apache.org/viewcvs?rev=349139&view=rev
Log:
Implemented DDLUTILS-45

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java?rev=349139&r1=349138&r2=349139&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java Sat Nov 26 11:48:23 2005
@@ -199,6 +199,16 @@
     public void createTables(Connection connection, Database model, boolean dropTablesFirst,
boolean continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for creating the tables defined in the database model.
+     * 
+     * @param model           The database model
+     * @param dropTablesFirst Whether to drop the tables prior to creating them (anew)
+     * @param continueOnError Whether to continue executing the sql commands when an error
occurred
+     * @return The SQL statements
+     */
+    public String createTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
throws DynaSqlException;
+
+    /**
      * Creates the tables defined in the database model.
      * 
      * @param model           The database model
@@ -220,6 +230,17 @@
     public void createTables(Connection connection, Database model, CreationParameters params,
boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for creating the tables defined in the database model.
+     * 
+     * @param model           The database model
+     * @param params          The parameters used in the creation
+     * @param dropTablesFirst Whether to drop the tables prior to creating them (anew)
+     * @param continueOnError Whether to continue executing the sql commands when an error
occurred
+     * @return The SQL statements
+     */
+    public String createTablesSql(Database model, CreationParameters params, boolean dropTablesFirst,
boolean continueOnError) throws DynaSqlException;
+
+    /**
      * Alters the database schema so that it match the given model. Drops and table modifications
will
      * not be made.
      *
@@ -240,6 +261,18 @@
     public void alterTables(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean
continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for altering the database schema so that it match the given model.
+     *
+     * @param desiredDb       The desired database schema
+     * @param doDrops         Whether columns, tables and indexes should be dropped if not
in the
+     *                        new schema
+     * @param modifyColumns   Whether columns should be altered for datatype, size as required
+     * @param continueOnError Whether to continue with the next sql statement when an error
occurred
+     * @return The SQL statements
+     */
+    public String alterTablesSql(Database desiredDb, boolean doDrops, boolean modifyColumns,
boolean continueOnError) throws DynaSqlException;
+
+    /**
      * Alters the database schema so that it match the given model. Drops and table modifications
will
      * not be made.
      *
@@ -262,6 +295,19 @@
     public void alterTables(Database desiredDb, CreationParameters params, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for altering the database schema so that it match the given model.
+     *
+     * @param desiredDb       The desired database schema
+     * @param params          The parameters used in the creation
+     * @param doDrops         Whether columns, tables and indexes should be dropped if not
in the
+     *                        new schema
+     * @param modifyColumns   Whether columns should be altered for datatype, size as required
+     * @param continueOnError Whether to continue with the next sql statement when an error
occurred
+     * @return The SQL statements
+     */
+    public String alterTablesSql(Database desiredDb, CreationParameters params, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
+
+    /**
      * Alters the database schema so that it match the given model. Drops and table modifications
will
      * not be made.
      *
@@ -284,6 +330,19 @@
     public void alterTables(Connection connection, Database desiredDb, boolean doDrops, boolean
modifyColumns, boolean continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for altering the database schema so that it match the given model.
+     *
+     * @param connection      A connection to the existing database that shall be modified
+     * @param desiredDb       The desired database schema
+     * @param doDrops         Whether columns, tables and indexes should be dropped if not
in the
+     *                        new schema
+     * @param modifyColumns   Whether columns should be altered for datatype, size as required
+     * @param continueOnError Whether to continue with the next sql statement when an error
occurred
+     * @return The SQL statements
+     */
+    public String alterTablesSql(Connection connection, Database desiredDb, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
+
+    /**
      * Alters the database schema so that it match the given model. Drops and table modifications
will
      * not be made.
      *
@@ -308,12 +367,35 @@
     public void alterTables(Connection connection, Database desiredDb, CreationParameters
params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
 
     /**
+     * Returns the SQL for altering the database schema so that it match the given model.
+     *
+     * @param connection      A connection to the existing database that shall be modified
+     * @param desiredDb       The desired database schema
+     * @param params          The parameters used in the creation
+     * @param doDrops         Whether columns, tables and indexes should be dropped if not
in the
+     *                        new schema
+     * @param modifyColumns   Whether columns should be altered for datatype, size as required
+     * @param continueOnError Whether to continue with the next sql statement when an error
occurred
+     * @return The SQL statements
+     */
+    public String alterTablesSql(Connection connection, Database desiredDb, CreationParameters
params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
+
+    /**
      * Drops the tables defined in the given database.
      * 
      * @param model           The database model
      * @param continueOnError Whether to continue executing the sql commands when an error
occurred
      */
     public void dropTables(Database model, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Returns the SQL for dropping the tables defined in the given database.
+     * 
+     * @param model           The database model
+     * @param continueOnError Whether to continue executing the sql commands when an error
occurred
+     * @return The SQL statements
+     */
+    public String dropTablesSql(Database model, boolean continueOnError) throws DynaSqlException;
 
     /**
      * Drops the tables defined in the given database.

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=349139&r1=349138&r2=349139&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Sat Nov
26 11:48:23 2005
@@ -269,6 +269,16 @@
      */
     public void createTables(Connection connection, Database model, boolean dropTablesFirst,
boolean continueOnError) throws DynaSqlException
     {
+        String sql = createTablesSql(model, dropTablesFirst, continueOnError);
+
+        evaluateBatch(connection, sql, continueOnError);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String createTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
throws DynaSqlException
+    {
         String sql = null;
 
         try
@@ -283,7 +293,7 @@
         {
             // won't happen because we're using a string writer
         }
-        evaluateBatch(connection, sql, continueOnError);
+        return sql;
     }
 
     /**
@@ -308,6 +318,16 @@
      */
     public void createTables(Connection connection, Database model, CreationParameters params,
boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
     {
+        String sql = createTablesSql(model, params, dropTablesFirst, continueOnError);
+
+        evaluateBatch(connection, sql, continueOnError);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String createTablesSql(Database model, CreationParameters params, boolean dropTablesFirst,
boolean continueOnError) throws DynaSqlException
+    {
         String sql = null;
 
         try
@@ -322,7 +342,7 @@
         {
             // won't happen because we're using a string writer
         }
-        evaluateBatch(connection, sql, continueOnError);
+        return sql;
     }
 
     /**
@@ -353,6 +373,23 @@
     /**
      * {@inheritDoc}
      */
+    public String alterTablesSql(Database desiredDb, boolean doDrops, boolean modifyColumns,
boolean continueOnError) throws DynaSqlException
+    {
+        Connection connection = borrowConnection();
+
+        try
+        {
+            return alterTablesSql(connection, desiredDb, doDrops, modifyColumns, continueOnError);
+        }
+        finally
+        {
+            returnConnection(connection);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError)
throws DynaSqlException
     {
         alterTables(desiredDb, params, false, false, continueOnError);
@@ -378,6 +415,23 @@
     /**
      * {@inheritDoc}
      */
+    public String alterTablesSql(Database desiredDb, CreationParameters params, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException
+    {
+        Connection connection = borrowConnection();
+
+        try
+        {
+            return alterTablesSql(connection, desiredDb, params, doDrops, modifyColumns,
continueOnError);
+        }
+        finally
+        {
+            returnConnection(connection);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void alterTables(Connection connection, Database desiredDb, boolean continueOnError)
throws DynaSqlException
     {
         alterTables(connection, desiredDb, false, false, continueOnError);
@@ -388,6 +442,16 @@
      */
     public void alterTables(Connection connection, Database desiredModel, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException
     {
+        String sql = alterTablesSql(connection, desiredModel, doDrops, modifyColumns, continueOnError);
+
+        evaluateBatch(connection, sql, continueOnError);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String alterTablesSql(Connection connection, Database desiredModel, boolean doDrops,
boolean modifyColumns, boolean continueOnError) throws DynaSqlException
+    {
         String   sql          = null;
         Database currentModel = readModelFromDatabase(connection);
 
@@ -403,7 +467,7 @@
         {
             // won't happen because we're using a string writer
         }
-        evaluateBatch(connection, sql, continueOnError);
+        return sql;
     }
 
     /**
@@ -419,6 +483,16 @@
      */
     public void alterTables(Connection connection, Database desiredModel, CreationParameters
params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
     {
+        String sql = alterTablesSql(connection, desiredModel, params, doDrops, modifyColumns,
continueOnError);
+
+        evaluateBatch(connection, sql, continueOnError);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String alterTablesSql(Connection connection, Database desiredModel, CreationParameters
params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
+    {
         String   sql          = null;
         Database currentModel = readModelFromDatabase(connection);
 
@@ -434,7 +508,7 @@
         {
             // won't happen because we're using a string writer
         }
-        evaluateBatch(connection, sql, continueOnError);
+        return sql;
     }
 
     /**
@@ -459,6 +533,16 @@
      */
     public void dropTables(Connection connection, Database model, boolean continueOnError)
throws DynaSqlException 
     {
+        String sql = dropTablesSql(model, continueOnError);
+
+        evaluateBatch(connection, sql, continueOnError);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String dropTablesSql(Database model, boolean continueOnError) throws DynaSqlException

+    {
         String sql = null;
 
         try
@@ -473,7 +557,7 @@
         {
             // won't happen because we're using a string writer
         }
-        evaluateBatch(connection, sql, continueOnError);
+        return sql;
     }
 
     /**



Mime
View raw message