tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r686982 - in /tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb: generator/impl/UpdateGenerator.java impl/ChangeFactory.java impl/ChangeSummarizer.java
Date Tue, 19 Aug 2008 08:26:36 GMT
Author: lresende
Date: Tue Aug 19 01:26:35 2008
New Revision: 686982

URL: http://svn.apache.org/viewvc?rev=686982&view=rev
Log:
TUSCANY-2551 - Applying Florian's patch to correct invalid SQL when data object has no changed
fields

Modified:
    tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java
    tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java
    tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java

Modified: tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java?rev=686982&r1=686981&r2=686982&view=diff
==============================================================================
--- tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java
(original)
+++ tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/UpdateGenerator.java
Tue Aug 19 01:26:35 2008
@@ -70,17 +70,23 @@
         List parameters = new ArrayList();
         Type type = changedObject.getType();
         TableWrapper tableWrapper = new TableWrapper(table);
+        // get changed fields 
+        ChangeSummary summary = changedObject.getDataGraph().getChangeSummary();
+        HashSet changedFields = getChangedFields(mapping, summary, changedObject, tableWrapper);

+        // if there are no changed fields return null
+        if (changedFields.size() == 0) {
+        	return null; 
+        }
+        // compose statement 
         StringBuffer statement = new StringBuffer("update ");
         if(mapping.getConfig().isDatabaseSchemaNameSupported()){
         	statement.append(table.getSchemaName()+"."+table.getTableName());
         }
         else{
-        statement.append(table.getTableName());
+        	statement.append(table.getTableName());
         }
         statement.append(" set ");
 
-        ChangeSummary summary = changedObject.getDataGraph().getChangeSummary();
-        HashSet changedFields = getChangedFields(mapping, summary, changedObject, tableWrapper);
         Iterator i = changedFields.iterator();
       
         int idx = 1;

Modified: tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java?rev=686982&r1=686981&r2=686982&view=diff
==============================================================================
--- tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java
(original)
+++ tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java
Tue Aug 19 01:26:35 2008
@@ -65,9 +65,14 @@
         deleteCommand = cmd;
     }
 
-    ChangeOperation createUpdateOperation(DataObject changedObject, String propagatedID)
{
-        return new UpdateOperation(getUpdateCommand(changedObject), changedObject, propagatedID);
-    }
+    ChangeOperation createUpdateOperation(DataObject changedObject,	String propagatedID)
{
+		UpdateCommandImpl cmd = getUpdateCommand(changedObject);
+		if (cmd == null) {
+			return null;
+		} else {
+			return new UpdateOperation(cmd, changedObject, propagatedID);
+		}
+	}
 
     ChangeOperation createUpdateOperation(DataObject changedObject) {
         return createUpdateOperation(changedObject, null);
@@ -160,9 +165,16 @@
                 updateCommand = new UpdateCommandImpl(update);
             }
         }
-        updateCommand.setConnection(connection);
-        updateCommand.configWrapper = mapping;
 
+        if (updateCommand != null) {
+	        updateCommand.setConnection(connection);
+	        updateCommand.configWrapper = mapping;
+        } else {
+        	if(this.logger.isDebugEnabled()) {
+        		this.logger.debug("Update command is NULL");
+        	}
+        }
+        
         if (this.logger.isDebugEnabled()) {
             this.logger.debug("Returning updateCommand: " + updateCommand);
         }

Modified: tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java
URL: http://svn.apache.org/viewvc/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java?rev=686982&r1=686981&r2=686982&view=diff
==============================================================================
--- tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java
(original)
+++ tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeSummarizer.java
Tue Aug 19 01:26:35 2008
@@ -112,7 +112,15 @@
                     this.logger.debug("Attribute Change for " + changedObject.getType().getName());
                 }
                 String propagatedID = (String) generatedKeys.get(changedObject.getType().getName());
-                changes.addUpdate(factory.createUpdateOperation(changedObject, propagatedID));
+                ChangeOperation op = factory.createUpdateOperation(changedObject, propagatedID);
+                if (op != null) {
+                	changes.addUpdate(op);
+                } else {
+                	if(this.logger.isDebugEnabled()) {
+                		this.logger.debug("Update Operation is NULL");
+                	}
+                }
+
             } else {
                 List values = changeSummary.getOldValues(changedObject);
                 Iterator i = values.iterator();
@@ -128,7 +136,15 @@
                         }
                         if (hasState(ref, changedObject)) {
                             ChangeFactory factory = getRegistry().getFactory(changedObject.getType());
-                            changes.addUpdate(factory.createUpdateOperation(changedObject));
+                            ChangeOperation op = factory.createUpdateOperation(changedObject);
+                            if (op != null) {
+                            	changes.addUpdate(op);
+                            } else {
+                            	if(this.logger.isDebugEnabled()) {
+                            		this.logger.debug("Update Operation is NULL");
+                            	}                            	
+                            }
+
                         }
                     }
                 }



Mime
View raw message