db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r488085 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/PlatformImplBase.java java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java test/org/apache/ddlutils/io/TestMisc.java
Date Mon, 18 Dec 2006 00:16:20 GMT
Author: tomdz
Date: Sun Dec 17 16:16:19 2006
New Revision: 488085

URL: http://svn.apache.org/viewvc?view=rev&rev=488085
Log:
Identity override is now off by default
Exposed controlling identity override in the WriteDataToDatabase subtask

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?view=diff&rev=488085&r1=488084&r2=488085
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Sun Dec
17 16:16:19 2006
@@ -86,7 +86,7 @@
     /** Whether delimited identifiers are used or not. */
     private boolean _delimitedIdentifierModeOn;
     /** Whether identity override is enabled. */
-    private boolean _identityOverrideOn = true;
+    private boolean _identityOverrideOn;
     /** Whether read foreign keys shall be sorted alphabetically. */
     private boolean _foreignKeysSorted;
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java?view=diff&rev=488085&r1=488084&r2=488085
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java Sun
Dec 17 16:16:19 2006
@@ -54,7 +54,26 @@
     private File      _singleDataFile = null;
     /** The input files. */
     private ArrayList _fileSets = new ArrayList();
-    
+    /** Whether explicit values for identity columns will be used. */
+    private boolean _useExplicitIdentityValues;
+
+    /**
+     * Defines whether values for identity columns in the data XML shall be used instead
of
+     * letting the database define the value. Unless <code>ensureForeignKeyOrder</code>
is
+     * set to false, setting this to <code>false</code> (the default) does not
affect foreign
+     * keys as DdlUtils will automatically update the values of the columns of foreign keys
+     * pointing to the inserted row with the database-created values. 
+     *
+     * @param useExplicitIdentityValues <code>true</code> if explicitly specified
identity
+     *                                  column values should be inserted instead of letting
+     *                                  the database define the values for these columns
+     * @ant.not-required Default is <code>false</code>
+     */
+    public void setUseExplicitIdentityValues(boolean useExplicitIdentityValues)
+    {
+        _useExplicitIdentityValues = useExplicitIdentityValues;
+    }
+
     /**
      * Adds a fileset.
      * 
@@ -132,6 +151,7 @@
 
         DataReader dataReader = null;
 
+        getPlatform().setIdentityOverrideOn(_useExplicitIdentityValues);
         try
         {
             dataReader = getDataIO().getConfiguredDataReader(getPlatform(), model);

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java?view=diff&rev=488085&r1=488084&r2=488085
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java Sun Dec 17 16:16:19 2006
@@ -77,6 +77,8 @@
 
         createDatabase(modelXml);
 
+        getPlatform().setIdentityOverrideOn(true);
+
         insertRow("misc1", new Object[] { new Integer(10), new Integer(1) });
         insertRow("misc1", new Object[] { new Integer(12), new Integer(2) });
         insertRow("misc1", new Object[] { new Integer(13), new Integer(3) });
@@ -159,6 +161,12 @@
      */
     public void testIdentityOverrideOff() throws Exception
     {
+        if (!getPlatformInfo().isIdentityOverrideAllowed())
+        {
+            // TODO: for testing these platforms, we need deleteRows
+            return;
+        }
+
         final String modelXml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
@@ -176,6 +184,8 @@
             "</database>";
 
         createDatabase(modelXml);
+
+        getPlatform().setIdentityOverrideOn(true);
 
         insertRow("misc1", new Object[] { new Integer(10), new Integer(1) });
         insertRow("misc1", new Object[] { new Integer(12), new Integer(2) });



Mime
View raw message