db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r491485 - in /db/ddlutils/trunk: build-sample.xml src/java/org/apache/ddlutils/io/DataToDatabaseSink.java src/java/org/apache/ddlutils/task/DatabaseTaskBase.java src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
Date Sun, 31 Dec 2006 21:02:11 GMT
Author: tomdz
Date: Sun Dec 31 13:02:10 2006
New Revision: 491485

URL: http://svn.apache.org/viewvc?view=rev&rev=491485
Log:
Minor tweaks to the database data sink
Added debug output for defered rows

Modified:
    db/ddlutils/trunk/build-sample.xml
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java

Modified: db/ddlutils/trunk/build-sample.xml
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/build-sample.xml?view=diff&rev=491485&r1=491484&r2=491485
==============================================================================
--- db/ddlutils/trunk/build-sample.xml (original)
+++ db/ddlutils/trunk/build-sample.xml Sun Dec 31 13:02:10 2006
@@ -29,13 +29,14 @@
 
   <!-- These properties can be overriden on the commandline using -D --> 
   <property name="schemafiles" value="testmodel.xml"/>
+  <property name="datafile" value="testdata.xml"/>
   <property name="catalogpattern" value=""/>
   <property name="schemapattern" value=""/>
   <property name="sqloutputfile" value="schema.sql"/>
   <property name="platform" value=""/>
   <property name="alterdatabase" value="true"/>
   <property name="delimitedsqlidentifiers" value="false"/>
-  <property name="verbosity" value="debug"/>
+  <property name="verbosity" value="info"/>
   
   <!-- The classpath used for running the tasks -->
   <path id="project-classpath">

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java?view=diff&rev=491485&r1=491484&r2=491485
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java Sun Dec 31 13:02:10
2006
@@ -189,7 +189,32 @@
         }
         if (!_waitingObjects.isEmpty())
         {
-            throw new DataSinkException("There are "+_waitingObjects.size()+" objects still
not written because of missing referenced objects");
+            if (_log.isDebugEnabled())
+            {
+                for (Iterator it = _waitingObjects.iterator(); it.hasNext();)
+                {
+                    WaitingObject obj   = (WaitingObject)it.next();
+                    Table         table = _model.getDynaClassFor(obj.getObject()).getTable();
+                    Identity      objId = buildIdentityFromPKs(table, obj.getObject());
+
+                    _log.debug("Row " + objId + " is still not written because it depends
on these yet unwritten rows");
+                    for (Iterator fkIt = obj.getPendingFKs(); fkIt.hasNext();)
+                    {
+                        Identity pendingFkId = (Identity)fkIt.next();
+
+                        _log.debug("  " + pendingFkId);
+                    }
+                        
+                }
+            }
+            if (_waitingObjects.size() == 1)
+            {
+                throw new DataSinkException("There is one row still not written because of
missing referenced rows");
+            }
+            else
+            {
+                throw new DataSinkException("There are " + _waitingObjects.size() + " rows
still not written because of missing referenced rows");
+            }
         }
     }
 
@@ -260,7 +285,7 @@
                 {
                     StringBuffer msg = new StringBuffer();
 
-                    msg.append("Defering insertion of bean ");
+                    msg.append("Defering insertion of row ");
                     msg.append(buildIdentityFromPKs(table, bean).toString());
                     msg.append(" because it is waiting for:");
                     for (Iterator it = waitingObj.getPendingFKs(); it.hasNext();)
@@ -310,7 +335,7 @@
                 {
                     Table waitingObjTable = ((SqlDynaClass)finishedObj.getDynaClass()).getTable();
 
-                    _log.debug("Inserted deferred bean "+buildIdentityFromPKs(waitingObjTable,
finishedObj));
+                    _log.debug("Inserted deferred row "+buildIdentityFromPKs(waitingObjTable,
finishedObj));
                 }
             }
         }
@@ -343,31 +368,34 @@
      */
     private void purgeBatchQueue() throws DataSinkException
     {
-        try
-        {
-            _platform.insert(_connection, _model, _batchQueue);
-            if (!_connection.getAutoCommit())
-            {
-                _connection.commit();
-            }
-            if (_log.isDebugEnabled())
-            {
-                _log.debug("Inserted "+_batchQueue.size()+" beans in batch mode ");
-            }
-        }
-        catch (Exception ex)
+        if (!_batchQueue.isEmpty())
         {
-            if (_haltOnErrors)
+            try
             {
-                _platform.returnConnection(_connection);
-                throw new DataSinkException(ex);
+                _platform.insert(_connection, _model, _batchQueue);
+                if (!_connection.getAutoCommit())
+                {
+                    _connection.commit();
+                }
+                if (_log.isDebugEnabled())
+                {
+                    _log.debug("Inserted " + _batchQueue.size() + " rows in batch mode ");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                _log.warn("Exception while inserting "+_batchQueue.size()+" beans via batch
mode into the database", ex);
+                if (_haltOnErrors)
+                {
+                    _platform.returnConnection(_connection);
+                    throw new DataSinkException(ex);
+                }
+                else
+                {
+                    _log.warn("Exception while inserting " + _batchQueue.size() + " rows
via batch mode into the database", ex);
+                }
             }
+            _batchQueue.clear();
         }
-        _batchQueue.clear();
     }
     
     /**
@@ -399,7 +427,7 @@
             }
             else
             {
-                _log.warn("Exception while inserting a bean into the database", ex);
+                _log.warn("Exception while inserting a row into the database", ex);
             }
         }
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java?view=diff&rev=491485&r1=491484&r2=491485
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java Sun Dec 31 13:02:10
2006
@@ -344,7 +344,7 @@
         props.setProperty("log4j.appender.A.layout", "org.apache.log4j.PatternLayout");
         props.setProperty("log4j.appender.A.layout.ConversionPattern", "%m%n");
         // we don't want debug logging from Digester/Betwixt
-        props.setProperty("log4j.logger.org.apache.commons", (_verbosity.isDebug() ? "DEBUG"
: "WARN"));
+        props.setProperty("log4j.logger.org.apache.commons", "WARN");
 
         LogManager.resetConfiguration();
         PropertyConfigurator.configure(props);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java?view=diff&rev=491485&r1=491484&r2=491485
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java Sun
Dec 31 13:02:10 2006
@@ -165,8 +165,8 @@
             if (shouldAlter)
             {
                 Database currentModel = (getCatalogPattern() != null) || (getSchemaPattern()
!= null) ?
-                                             platform.readModelFromDatabase(null, getCatalogPattern(),
getSchemaPattern(), null) :
-                                             platform.readModelFromDatabase(null);
+                                             platform.readModelFromDatabase("unnamed", getCatalogPattern(),
getSchemaPattern(), null) :
+                                             platform.readModelFromDatabase("unnamed");
 
                 platform.getSqlBuilder().alterDatabase(currentModel, model, params);
             }



Mime
View raw message