You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2007/09/25 04:48:40 UTC

svn commit: r579041 [1/6] - in /ibatis/trunk/java/mapper/mapper2/tools/abator/core: build/ doc/ src/org/apache/ibatis/abator/api/ src/org/apache/ibatis/abator/config/ src/org/apache/ibatis/abator/config/xml/ src/org/apache/ibatis/abator/internal/ src/o...

Author: jgbutler
Date: Mon Sep 24 19:48:38 2007
New Revision: 579041

URL: http://svn.apache.org/viewvc?rev=579041&view=rev
Log:
Abator: New updateByExample methods and tests refactoring

Added:
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2TestSuite.java
      - copied, changed from r574711, ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/CountByExampleTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/DeleteByExampleTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/DeleteByPrimaryKeyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/InsertTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/SelectByExampleTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/SelectByPrimaryKeyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/UpdateByExampleTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/UpdateByPrimaryKeyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/flat/java2/UpdateByExampleTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/hierarchical/java2/UpdateByExampleTests.java
Removed:
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java
Modified:
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOMethodNameCalculator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ColumnDefinition.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/AbatorRules.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties Mon Sep 24 19:48:38 2007
@@ -1,4 +1,4 @@
 #Abator build version info
-#Mon Aug 27 23:02:40 CDT 2007
+#Mon Sep 24 17:03:48 CDT 2007
 version=1.1.0
-buildNum=374
+buildNum=392

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt Mon Sep 24 19:48:38 2007
@@ -34,6 +34,7 @@
 11. Exposed new support for selecting tables and/or contexts to the
     command line and the Ant task 
 12. IBATIS-414 - make the Example and Criteria classes extendable
+13. Added countByExample generated method
 
 -------------------------------------------------------------------------------
 Version 1.0.0:

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOMethodNameCalculator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/DAOMethodNameCalculator.java Mon Sep 24 19:48:38 2007
@@ -109,4 +109,28 @@
      * @return the calculated name
      */
     String getCountByExampleMethodName(IntrospectedTable introspectedTable);
+    
+    /**
+     * Calculates and returns a name for the update by example selective method.
+     * 
+     * @param introspectedTable
+     * @return the calculated name
+     */
+    String getUpdateByExampleSelectiveMethodName(IntrospectedTable introspectedTable);    
+
+    /**
+     * Calculates and returns a name for the update by example with BLOBs method.
+     * 
+     * @param introspectedTable
+     * @return the calculated name
+     */
+    String getUpdateByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable);    
+
+    /**
+     * Calculates and returns a name for the update by example without BLOBs method.
+     * 
+     * @param introspectedTable
+     * @return the calculated name
+     */
+    String getUpdateByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable);    
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/SqlMapGenerator.java Mon Sep 24 19:48:38 2007
@@ -90,5 +90,11 @@
     
     String getCountByExampleStatementId();
 
+    String getUpdateByExampleSelectiveStatementId();
+    
+    String getUpdateByExampleStatementId();
+    
+    String getUpdateByExampleWithBLOBsStatementId();
+    
     List getGeneratedXMLFiles(IntrospectedTable introspectedTable, ProgressCallback callback);
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/TableConfiguration.java Mon Sep 24 19:48:38 2007
@@ -46,6 +46,8 @@
     
     private boolean countByExampleStatementEnabled;
     
+    private boolean updateByExampleStatementEnabled;
+    
 	private List columnOverrides;
 
 	private Map ignoredColumns;
@@ -81,6 +83,7 @@
 		deleteByPrimaryKeyStatementEnabled = true;
 		deleteByExampleStatementEnabled = true;
         countByExampleStatementEnabled = true;
+        updateByExampleStatementEnabled = true;
 	}
 
 	public boolean isDeleteByPrimaryKeyStatementEnabled() {
@@ -441,5 +444,14 @@
     public void setCountByExampleStatementEnabled(
             boolean countByExampleStatementEnabled) {
         this.countByExampleStatementEnabled = countByExampleStatementEnabled;
+    }
+
+    public boolean isUpdateByExampleStatementEnabled() {
+        return updateByExampleStatementEnabled;
+    }
+
+    public void setUpdateByExampleStatementEnabled(
+            boolean updateByExampleStatementEnabled) {
+        this.updateByExampleStatementEnabled = updateByExampleStatementEnabled;
     }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java Mon Sep 24 19:48:38 2007
@@ -325,6 +325,8 @@
                 .getProperty("enableDeleteByExample"); //$NON-NLS-1$
         String enableCountByExample = attributes
             .getProperty("enableCountByExample"); //$NON-NLS-1$
+        String enableUpdateByExample = attributes
+            .getProperty("enableUpdateByExample"); //$NON-NLS-1$
         String selectByPrimaryKeyQueryId = attributes
                 .getProperty("selectByPrimaryKeyQueryId"); //$NON-NLS-1$
         String selectByExampleQueryId = attributes
@@ -386,6 +388,11 @@
         if (StringUtility.stringHasValue(enableCountByExample)) {
             tc.setCountByExampleStatementEnabled("true" //$NON-NLS-1$
                     .equals(enableCountByExample));
+        }
+
+        if (StringUtility.stringHasValue(enableUpdateByExample)) {
+            tc.setUpdateByExampleStatementEnabled("true" //$NON-NLS-1$
+                    .equals(enableUpdateByExample));
         }
 
         if (StringUtility.stringHasValue(selectByPrimaryKeyQueryId)) {

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd Mon Sep 24 19:48:38 2007
@@ -147,6 +147,7 @@
   enableDeleteByPrimaryKey CDATA #IMPLIED
   enableDeleteByExample CDATA #IMPLIED
   enableCountByExample CDATA #IMPLIED
+  enableUpdateByExample CDATA #IMPLIED
   selectByPrimaryKeyQueryId CDATA #IMPLIED
   selectByExampleQueryId CDATA #IMPLIED
   modelType CDATA #IMPLIED

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultDAOMethodNameCalculator.java Mon Sep 24 19:48:38 2007
@@ -127,4 +127,31 @@
         return "countByExample"; //$NON-NLS-1$
     }
 
+    public String getUpdateByExampleSelectiveMethodName(IntrospectedTable introspectedTable) {
+        return "updateByExampleSelective"; //$NON-NLS-1$
+    }
+
+    public String getUpdateByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
+        AbatorRules rules = introspectedTable.getRules();
+        
+        if (!rules.generateUpdateByExampleWithoutBLOBs()) {
+            return "updateByExample"; //$NON-NLS-1$
+        } else if (rules.generateRecordWithBLOBsClass()) {
+            return "updateByExample"; //$NON-NLS-1$
+        } else {
+            return "updateByExampleWithBLOBs"; //$NON-NLS-1$
+        }
+    }
+
+    public String getUpdateByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
+        AbatorRules rules = introspectedTable.getRules();
+        
+        if (!rules.generateUpdateByExampleWithBLOBs()) {
+            return "updateByExample"; //$NON-NLS-1$
+        } else if (rules.generateRecordWithBLOBsClass()) {
+            return "updateByExample"; //$NON-NLS-1$
+        } else {
+            return "updateByExampleWithoutBLOBs"; //$NON-NLS-1$
+        }
+    }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/ExtendedDAOMethodNameCalculator.java Mon Sep 24 19:48:38 2007
@@ -180,4 +180,49 @@
         return sb.toString();
     }
 
+    public String getUpdateByExampleSelectiveMethodName(IntrospectedTable introspectedTable) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("update"); //$NON-NLS-1$
+        sb.append(introspectedTable.getTable().getDomainObjectName());
+        sb.append("ByExampleSelective"); //$NON-NLS-1$
+        
+        return sb.toString();
+    }
+
+    public String getUpdateByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("update"); //$NON-NLS-1$
+        sb.append(introspectedTable.getTable().getDomainObjectName());
+        
+        AbatorRules rules = introspectedTable.getRules();
+        
+        if (!rules.generateUpdateByExampleWithoutBLOBs()) {
+            sb.append("ByExample"); //$NON-NLS-1$
+        } else if (rules.generateRecordWithBLOBsClass()) {
+            sb.append("ByExample"); //$NON-NLS-1$
+        } else {
+            sb.append("ByExampleWithBLOBs"); //$NON-NLS-1$
+        }
+        
+        return sb.toString();
+    }
+
+    public String getUpdateByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append("update"); //$NON-NLS-1$
+        sb.append(introspectedTable.getTable().getDomainObjectName());
+        
+        AbatorRules rules = introspectedTable.getRules();
+        
+        if (!rules.generateUpdateByExampleWithBLOBs()) {
+            sb.append("ByExample"); //$NON-NLS-1$
+        } else if (rules.generateRecordWithBLOBsClass()) {
+            sb.append("ByExample"); //$NON-NLS-1$
+        } else {
+            sb.append("ByExampleWithoutBLOBs"); //$NON-NLS-1$
+        }
+        
+        return sb.toString();
+    }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ColumnDefinition.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ColumnDefinition.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ColumnDefinition.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ColumnDefinition.java Mon Sep 24 19:48:38 2007
@@ -174,7 +174,19 @@
     }
 
     public String getJavaProperty() {
-        return javaProperty;
+        return getJavaProperty(null);
+    }
+
+    public String getJavaProperty(String prefix) {
+        if (prefix == null) {
+            return javaProperty;
+        }
+        
+        StringBuffer sb = new StringBuffer();
+        sb.append(prefix);
+        sb.append(javaProperty);
+        
+        return sb.toString();
     }
 
     public void setJavaProperty(String javaProperty) {
@@ -252,10 +264,14 @@
     }
     
     public String getIbatisFormattedParameterClause() {
+        return getIbatisFormattedParameterClause(null);
+    }
+    
+    public String getIbatisFormattedParameterClause(String prefix) {
         StringBuffer sb = new StringBuffer();
         
         sb.append('#');
-        sb.append(getJavaProperty());
+        sb.append(getJavaProperty(prefix));
         
         if (StringUtility.stringHasValue(typeHandler)) {
             sb.append(",jdbcType="); //$NON-NLS-1$

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java Mon Sep 24 19:48:38 2007
@@ -33,6 +33,7 @@
 import org.apache.ibatis.abator.api.dom.java.CompilationUnit;
 import org.apache.ibatis.abator.api.dom.java.Field;
 import org.apache.ibatis.abator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.abator.api.dom.java.InnerClass;
 import org.apache.ibatis.abator.api.dom.java.Interface;
 import org.apache.ibatis.abator.api.dom.java.JavaVisibility;
 import org.apache.ibatis.abator.api.dom.java.Method;
@@ -45,6 +46,7 @@
 import org.apache.ibatis.abator.internal.DefaultDAOMethodNameCalculator;
 import org.apache.ibatis.abator.internal.ExtendedDAOMethodNameCalculator;
 import org.apache.ibatis.abator.internal.db.ColumnDefinition;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
 import org.apache.ibatis.abator.internal.util.JavaBeansUtil;
 import org.apache.ibatis.abator.internal.util.StringUtility;
 import org.apache.ibatis.abator.internal.util.messages.Messages;
@@ -263,9 +265,10 @@
             answer.addMethod((Method) iter.next());
         }
 
+        AbatorRules rules = introspectedTable.getRules();
         List methods;
         
-        if (introspectedTable.getRules().generateInsert()) {
+        if (rules.generateInsert()) {
             methods = getInsertMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -275,7 +278,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
             methods = getUpdateByPrimaryKeyWithoutBLOBsMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -285,7 +288,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithBLOBs()) {
             methods = getUpdateByPrimaryKeyWithBLOBsMethods(introspectedTable,
                     false, answer);
             if (methods != null) {
@@ -296,7 +299,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
+        if (rules.generateUpdateByPrimaryKeySelective()) {
             methods = getUpdateByPrimaryKeySelectiveMethods(introspectedTable,
                     false, answer);
             if (methods != null) {
@@ -307,7 +310,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) {
+        if (rules.generateSelectByExampleWithoutBLOBs()) {
             methods = getSelectByExampleWithoutBLOBsMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -317,7 +320,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
+        if (rules.generateSelectByExampleWithBLOBs()) {
             methods = getSelectByExampleWithBLOBsMethods(introspectedTable, false,
                     answer);
             if (methods != null) {
@@ -328,7 +331,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
+        if (rules.generateSelectByPrimaryKey()) {
             methods = getSelectByPrimaryKeyMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -338,7 +341,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByExample()) {
+        if (rules.generateDeleteByExample()) {
             methods = getDeleteByExampleMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -348,7 +351,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByPrimaryKey()) {
+        if (rules.generateDeleteByPrimaryKey()) {
             methods = getDeleteByPrimaryKeyMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -358,7 +361,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateCountByExample()) {
+        if (rules.generateCountByExample()) {
             methods = getCountByExampleMethods(introspectedTable, false, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -368,6 +371,45 @@
             }
         }
         
+        if (rules.generateUpdateByExampleSelective()) {
+            methods = getUpdateByExampleSelectiveMethods(introspectedTable, false, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
+        if (rules.generateUpdateByExampleWithBLOBs()) {
+            methods = getUpdateByExampleWithBLOBsMethods(introspectedTable, false, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+
+        if (rules.generateUpdateByExampleWithoutBLOBs()) {
+            methods = getUpdateByExampleWithoutBLOBsMethods(introspectedTable, false, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
+        if (rules.generateUpdateByExampleSelective()
+                || rules.generateUpdateByExampleWithBLOBs()
+                || rules.generateUpdateByExampleWithoutBLOBs()) {
+            InnerClass innerClass = getUpdateByExampleParms(introspectedTable, answer);
+            if (innerClass != null) {
+                answer.addInnerClass(innerClass);
+            }
+        }
+
         afterImplementationGenerationHook(introspectedTable, answer);
         
         return answer;
@@ -414,9 +456,10 @@
             answer.addImportedType((FullyQualifiedJavaType) iter.next());
         }
 
+        AbatorRules rules = introspectedTable.getRules();
         List methods;
         
-        if (introspectedTable.getRules().generateInsert()) {
+        if (rules.generateInsert()) {
             methods = getInsertMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -426,7 +469,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
             methods = getUpdateByPrimaryKeyWithoutBLOBsMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -436,7 +479,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithBLOBs()) {
             methods = getUpdateByPrimaryKeyWithBLOBsMethods(introspectedTable,
                     true, answer);
             if (methods != null) {
@@ -447,7 +490,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
+        if (rules.generateUpdateByPrimaryKeySelective()) {
             methods = getUpdateByPrimaryKeySelectiveMethods(introspectedTable,
                     true, answer);
             if (methods != null) {
@@ -458,7 +501,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) {
+        if (rules.generateSelectByExampleWithoutBLOBs()) {
             methods = getSelectByExampleWithoutBLOBsMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -468,7 +511,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
+        if (rules.generateSelectByExampleWithBLOBs()) {
             methods = getSelectByExampleWithBLOBsMethods(introspectedTable, true,
                     answer);
             if (methods != null) {
@@ -479,7 +522,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
+        if (rules.generateSelectByPrimaryKey()) {
             methods = getSelectByPrimaryKeyMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -489,7 +532,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByExample()) {
+        if (rules.generateDeleteByExample()) {
             methods = getDeleteByExampleMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -499,7 +542,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByPrimaryKey()) {
+        if (rules.generateDeleteByPrimaryKey()) {
             methods = getDeleteByPrimaryKeyMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -509,7 +552,7 @@
             }
         }
 
-        if (introspectedTable.getRules().generateCountByExample()) {
+        if (rules.generateCountByExample()) {
             methods = getCountByExampleMethods(introspectedTable, true, answer);
             if (methods != null) {
                 iter = methods.iterator();
@@ -519,6 +562,36 @@
             }
         }
         
+        if (rules.generateUpdateByExampleSelective()) {
+            methods = getUpdateByExampleSelectiveMethods(introspectedTable, true, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
+        if (rules.generateUpdateByExampleWithBLOBs()) {
+            methods = getUpdateByExampleWithBLOBsMethods(introspectedTable, true, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+
+        if (rules.generateUpdateByExampleWithoutBLOBs()) {
+            methods = getUpdateByExampleWithoutBLOBsMethods(introspectedTable, true, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
         afterInterfaceGenerationHook(introspectedTable, answer);
         
         return answer;
@@ -1226,5 +1299,201 @@
 
     public void setAbatorContext(AbatorContext abatorContext) {
         this.abatorContext = abatorContext;
+    }
+
+    protected List getUpdateByExampleSelectiveMethods(
+            IntrospectedTable introspectedTable, boolean interfaceMethod,
+            CompilationUnit compilationUnit) {
+
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType parameterType;
+        
+        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+            parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+        } else if (introspectedTable.getRules().generateBaseRecordClass()) {
+            parameterType = javaModelGenerator.getBaseRecordType(table);
+        } else {
+            parameterType = javaModelGenerator.getPrimaryKeyType(table);
+        }
+        
+        compilationUnit.addImportedType(parameterType);
+
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getIntInstance());
+        method.setName(methodNameCalculator.getUpdateByExampleSelectiveMethodName(introspectedTable));
+        method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
+        method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+        
+
+        Iterator iter = daoTemplate.getCheckedExceptions().iterator();
+        while (iter.hasNext()) {
+            FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) iter.next();
+            method.addException(fqjt);
+            compilationUnit.addImportedType(fqjt);
+        }
+
+        if (!interfaceMethod) {
+            // generate the implementation method
+            method.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
+            
+            StringBuffer sb = new StringBuffer();
+            
+            sb.append("int rows = "); //$NON-NLS-1$
+            
+            sb.append(daoTemplate.getUpdateMethod(sqlMapGenerator
+                    .getSqlMapNamespace(table), sqlMapGenerator
+                    .getUpdateByExampleSelectiveStatementId(), "parms")); //$NON-NLS-1$
+            method.addBodyLine(sb.toString());
+
+            method.addBodyLine("return rows;"); //$NON-NLS-1$
+        }
+
+        ArrayList answer = new ArrayList();
+        answer.add(method);
+
+        return answer;
+    }
+    
+    protected InnerClass getUpdateByExampleParms (IntrospectedTable introspectedTable,
+            CompilationUnit compilationUnit) {
+        FullyQualifiedTable table = introspectedTable.getTable();
+        compilationUnit.addImportedType(javaModelGenerator.getExampleType(table));
+        
+        InnerClass answer = new InnerClass(
+                new FullyQualifiedJavaType("UpdateByExampleParms")); //$NON-NLS-1$
+        answer.addComment(table);
+        answer.setVisibility(JavaVisibility.PRIVATE);
+        answer.setModifierStatic(true);
+        answer.setSuperClass(javaModelGenerator.getExampleType(table));
+        
+        Method method = new Method();
+        method.setConstructor(true);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setName(answer.getType().getShortName());
+        method.addParameter(
+                new Parameter(FullyQualifiedJavaType.getObjectInstance(),
+                        "record")); //$NON-NLS-1$
+        method.addParameter(
+                new Parameter(javaModelGenerator.getExampleType(table),
+                        "example")); //$NON-NLS-1$
+        method.addBodyLine("super(example);"); //$NON-NLS-1$
+        method.addBodyLine("this.record = record;"); //$NON-NLS-1$
+        answer.addMethod(method);
+        
+        Field field = new Field();
+        field.setVisibility(JavaVisibility.PRIVATE);
+        field.setType(FullyQualifiedJavaType.getObjectInstance());
+        field.setName("record"); //$NON-NLS-1$
+        answer.addField(field);
+        
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getObjectInstance());
+        method.setName("getRecord"); //$NON-NLS-1$
+        method.addBodyLine("return record;"); //$NON-NLS-1$
+        answer.addMethod(method);
+        
+        return answer;
+    }
+
+    protected List getUpdateByExampleWithBLOBsMethods(
+            IntrospectedTable introspectedTable, boolean interfaceMethod,
+            CompilationUnit compilationUnit) {
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType parameterType; 
+        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+            parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+        } else {
+            parameterType = javaModelGenerator.getBaseRecordType(table);
+        }
+
+        compilationUnit.addImportedType(parameterType);
+
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getIntInstance());
+        method.setName(methodNameCalculator.getUpdateByExampleWithBLOBsMethodName(introspectedTable));
+        method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
+        method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+
+        Iterator iter = daoTemplate.getCheckedExceptions().iterator();
+        while (iter.hasNext()) {
+            FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) iter.next();
+            method.addException(fqjt);
+            compilationUnit.addImportedType(fqjt);
+        }
+
+        if (!interfaceMethod) {
+            // generate the implementation method
+            method.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
+            
+            StringBuffer sb = new StringBuffer();
+
+            sb.append("int rows = "); //$NON-NLS-1$
+            sb.append(daoTemplate.getUpdateMethod(sqlMapGenerator
+                    .getSqlMapNamespace(table), sqlMapGenerator
+                    .getUpdateByExampleWithBLOBsStatementId(), "parms")); //$NON-NLS-1$
+            method.addBodyLine(sb.toString());
+
+            method.addBodyLine("return rows;"); //$NON-NLS-1$
+        }
+
+        ArrayList answer = new ArrayList();
+        answer.add(method);
+
+        return answer;
+    }
+
+    protected List getUpdateByExampleWithoutBLOBsMethods(
+            IntrospectedTable introspectedTable, boolean interfaceMethod,
+            CompilationUnit compilationUnit) {
+
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType parameterType; 
+        if (introspectedTable.getRules().generateBaseRecordClass()) {
+            parameterType = javaModelGenerator.getBaseRecordType(table);
+        } else {
+            parameterType = javaModelGenerator.getPrimaryKeyType(table);
+        }
+
+        compilationUnit.addImportedType(parameterType);
+
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getIntInstance());
+        method.setName(methodNameCalculator.getUpdateByExampleWithoutBLOBsMethodName(introspectedTable));
+        method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
+        method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+
+        Iterator iter = daoTemplate.getCheckedExceptions().iterator();
+        while (iter.hasNext()) {
+            FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) iter.next();
+            method.addException(fqjt);
+            compilationUnit.addImportedType(fqjt);
+        }
+
+        if (!interfaceMethod) {
+            // generate the implementation method
+            method.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
+            
+            StringBuffer sb = new StringBuffer();
+
+            sb.append("int rows = "); //$NON-NLS-1$
+            sb.append(daoTemplate.getUpdateMethod(sqlMapGenerator
+                    .getSqlMapNamespace(table), sqlMapGenerator
+                    .getUpdateByExampleStatementId(), "parms")); //$NON-NLS-1$
+            method.addBodyLine(sb.toString());
+
+            method.addBodyLine("return rows;"); //$NON-NLS-1$
+        }
+
+        ArrayList answer = new ArrayList();
+        answer.add(method);
+
+        return answer;
     }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java Mon Sep 24 19:48:38 2007
@@ -25,6 +25,7 @@
 import org.apache.ibatis.abator.api.IntrospectedTable;
 import org.apache.ibatis.abator.api.dom.java.CompilationUnit;
 import org.apache.ibatis.abator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.abator.api.dom.java.InnerClass;
 import org.apache.ibatis.abator.api.dom.java.JavaVisibility;
 import org.apache.ibatis.abator.api.dom.java.Method;
 import org.apache.ibatis.abator.api.dom.java.Parameter;
@@ -459,5 +460,25 @@
         method.addBodyLine("return parms;"); //$NON-NLS-1$
 
         return method;
+    }
+
+    protected List getUpdateByExampleSelectiveMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
+
+    protected List getUpdateByExampleWithBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
+
+    protected List getUpdateByExampleWithoutBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
+
+    protected InnerClass getUpdateByExampleParms(IntrospectedTable introspectedTable, CompilationUnit compilationUnit) {
+        // this method is not supported in the legacy generator set
+        return null;
     }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java Mon Sep 24 19:48:38 2007
@@ -38,6 +38,7 @@
 import org.apache.ibatis.abator.config.AbatorContext;
 import org.apache.ibatis.abator.config.PropertyRegistry;
 import org.apache.ibatis.abator.internal.db.ColumnDefinition;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
 import org.apache.ibatis.abator.internal.util.JavaBeansUtil;
 import org.apache.ibatis.abator.internal.util.StringUtility;
 import org.apache.ibatis.abator.internal.util.messages.Messages;
@@ -711,6 +712,33 @@
         TopLevelClass topLevelClass = new TopLevelClass(type);
         topLevelClass.setVisibility(JavaVisibility.PUBLIC);
 
+        // add default constructor
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setConstructor(true);
+        method.setName(type.getShortName());
+        method.addBodyLine("oredCriteria = new ArrayList();"); //$NON-NLS-1$
+        topLevelClass.addMethod(method);
+        
+        // add shallow copy contructor if the update by
+        // example methods are enabled - because the parameter
+        // class for update by example methods will subclass this class
+        AbatorRules rules = introspectedTable.getRules();
+        if (rules.generateUpdateByExampleSelective()
+                || rules.generateUpdateByExampleWithBLOBs()
+                ||rules.generateUpdateByExampleWithoutBLOBs()) {
+            method = new Method();
+            method.addComment(table);
+            method.setVisibility(JavaVisibility.PROTECTED);
+            method.setConstructor(true);
+            method.setName(type.getShortName());
+            method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
+            method.addBodyLine("this.orderByClause = example.orderByClause;"); //$NON-NLS-1$
+            method.addBodyLine("this.oredCriteria = example.oredCriteria;"); //$NON-NLS-1$
+            topLevelClass.addMethod(method);
+        }
+        
         // add field, getter, setter for orderby clause
         Field field = new Field();
         field.addComment(table);
@@ -719,7 +747,7 @@
         field.setName("orderByClause"); //$NON-NLS-1$
         topLevelClass.addField(field);
 
-        Method method = new Method();
+        method = new Method();
         method.addComment(table);
         method.setVisibility(JavaVisibility.PUBLIC);
         method.setName("setOrderByClause"); //$NON-NLS-1$
@@ -746,7 +774,6 @@
 
         field.setType(fqjt);
         field.setName("oredCriteria"); //$NON-NLS-1$
-        field.setInitializationString("new ArrayList()"); //$NON-NLS-1$
         topLevelClass.addField(field);
 
         method = new Method();

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java Mon Sep 24 19:48:38 2007
@@ -31,6 +31,7 @@
 import org.apache.ibatis.abator.api.dom.java.Parameter;
 import org.apache.ibatis.abator.api.dom.java.TopLevelClass;
 import org.apache.ibatis.abator.internal.db.ColumnDefinition;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
 import org.apache.ibatis.abator.internal.util.JavaBeansUtil;
 import org.apache.ibatis.abator.internal.util.StringUtility;
 
@@ -55,7 +56,34 @@
         FullyQualifiedJavaType type = getExampleType(table);
         TopLevelClass topLevelClass = new TopLevelClass(type);
         topLevelClass.setVisibility(JavaVisibility.PUBLIC);
-
+        
+        // add default constructor
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setConstructor(true);
+        method.setName(type.getShortName());
+        method.addBodyLine("oredCriteria = new ArrayList<Criteria>();"); //$NON-NLS-1$
+        topLevelClass.addMethod(method);
+        
+        // add shallow copy contructor if the update by
+        // example methods are enabled - because the parameter
+        // class for update by example methods will subclass this class
+        AbatorRules rules = introspectedTable.getRules();
+        if (rules.generateUpdateByExampleSelective()
+                || rules.generateUpdateByExampleWithBLOBs()
+                ||rules.generateUpdateByExampleWithoutBLOBs()) {
+            method = new Method();
+            method.addComment(table);
+            method.setVisibility(JavaVisibility.PROTECTED);
+            method.setConstructor(true);
+            method.setName(type.getShortName());
+            method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
+            method.addBodyLine("this.orderByClause = example.orderByClause;"); //$NON-NLS-1$
+            method.addBodyLine("this.oredCriteria = example.oredCriteria;"); //$NON-NLS-1$
+            topLevelClass.addMethod(method);
+        }
+        
         // add field, getter, setter for orderby clause
         Field field = new Field();
         field.addComment(table);
@@ -64,7 +92,7 @@
         field.setName("orderByClause"); //$NON-NLS-1$
         topLevelClass.addField(field);
 
-        Method method = new Method();
+        method = new Method();
         method.addComment(table);
         method.setVisibility(JavaVisibility.PUBLIC);
         method.setName("setOrderByClause"); //$NON-NLS-1$
@@ -92,7 +120,6 @@
 
         field.setType(fqjt);
         field.setName("oredCriteria"); //$NON-NLS-1$
-        field.setInitializationString("new ArrayList<Criteria>()"); //$NON-NLS-1$
         topLevelClass.addField(field);
 
         method = new Method();

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/AbatorRules.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/AbatorRules.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/AbatorRules.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/rules/AbatorRules.java Mon Sep 24 19:48:38 2007
@@ -255,7 +255,8 @@
     public boolean generateExampleClass() {
         boolean rc = tableConfiguration.isSelectByExampleStatementEnabled()
                 || tableConfiguration.isDeleteByExampleStatementEnabled()
-                || tableConfiguration.isCountByExampleStatementEnabled();
+                || tableConfiguration.isCountByExampleStatementEnabled()
+                || tableConfiguration.isUpdateByExampleStatementEnabled();
     
         return rc;
     }
@@ -266,6 +267,27 @@
         return rc;
     }
 
+    public boolean generateUpdateByExampleSelective() {
+        boolean rc = tableConfiguration.isUpdateByExampleStatementEnabled();
+
+        return rc;
+    }
+
+    public boolean generateUpdateByExampleWithoutBLOBs() {
+        boolean rc = tableConfiguration.isUpdateByExampleStatementEnabled()
+            && (columnDefinitions.hasPrimaryKeyColumns()
+            || columnDefinitions.hasBaseColumns());
+        
+        return rc;
+    }
+    
+    public boolean generateUpdateByExampleWithBLOBs() {
+        boolean rc = tableConfiguration.isUpdateByExampleStatementEnabled()
+            && columnDefinitions.hasBLOBColumns();
+    
+        return rc;
+    }
+    
     /**
      * Implements the rule for determining whether to generate a primary key
      * class.  If you return false from this method, and the table has

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java Mon Sep 24 19:48:38 2007
@@ -38,6 +38,7 @@
 import org.apache.ibatis.abator.config.GeneratedKey;
 import org.apache.ibatis.abator.config.PropertyRegistry;
 import org.apache.ibatis.abator.internal.db.ColumnDefinition;
+import org.apache.ibatis.abator.internal.rules.AbatorRules;
 import org.apache.ibatis.abator.internal.util.StringUtility;
 import org.apache.ibatis.abator.internal.util.messages.Messages;
 
@@ -171,98 +172,120 @@
         answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
                 getSqlMapNamespace(table)));
 
+        AbatorRules rules = introspectedTable.getRules();
         XmlElement element;
-        if (introspectedTable.getRules().generateBaseResultMap()) {
+        if (rules.generateBaseResultMap()) {
             element = getBaseResultMapElement(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateResultMapWithBLOBs()) {
+        if (rules.generateResultMapWithBLOBs()) {
             element = getResultMapWithBLOBsElement(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateSQLExampleWhereClause()) {
+        if (rules.generateSQLExampleWhereClause()) {
             element = getByExampleWhereClauseFragment(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
+        if (rules.generateSelectByPrimaryKey()) {
             element = getSelectByPrimaryKey(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) {
+        if (rules.generateSelectByExampleWithoutBLOBs()) {
             element = getSelectByExample(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
+        if (rules.generateSelectByExampleWithBLOBs()) {
             element = getSelectByExampleWithBLOBs(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByPrimaryKey()) {
+        if (rules.generateDeleteByPrimaryKey()) {
             element = getDeleteByPrimaryKey(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateDeleteByExample()) {
+        if (rules.generateDeleteByExample()) {
             element = getDeleteByExample(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateInsert()) {
+        if (rules.generateInsert()) {
             element = getInsertElement(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithBLOBs()) {
             element = getUpdateByPrimaryKeyWithBLOBs(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
+        if (rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
             element = getUpdateByPrimaryKeyWithoutBLOBs(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
 
-        if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
+        if (rules.generateUpdateByPrimaryKeySelective()) {
             element = getUpdateByPrimaryKeySelective(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
         
-        if (introspectedTable.getRules().generateCountByExample()) {
+        if (rules.generateCountByExample()) {
             element = getCountByExample(introspectedTable);
             if (element != null) {
                 answer.addElement(element);
             }
         }
         
+        if (rules.generateUpdateByExampleSelective()) {
+            element = getUpdateByExampleSelective(introspectedTable);
+            if (element != null) {
+                answer.addElement(element);
+            }
+        }
+        
+        if (rules.generateUpdateByExampleWithBLOBs()) {
+            element = getUpdateByExampleWithBLOBs(introspectedTable);
+            if (element != null) {
+                answer.addElement(element);
+            }
+        }
+
+        if (rules.generateUpdateByExampleWithoutBLOBs()) {
+            element = getUpdateByExampleWithoutBLOBs(introspectedTable);
+            if (element != null) {
+                answer.addElement(element);
+            }
+        }
+
         return answer;
     }
 
@@ -1051,6 +1074,10 @@
         return "abatorgenerated_updateByPrimaryKeySelective"; //$NON-NLS-1$
     }
     
+    public String getUpdateByExampleSelectiveStatementId() {
+        return "abatorgenerated_updateByExampleSelective"; //$NON-NLS-1$
+    }
+    
     /**
      * Calculates the package for the current table.
      * 
@@ -1078,7 +1105,7 @@
     }
 
     /**
-     * Calculates the name of the example where clause element
+     * Calculates the name of the example where clause element.
      * 
      * @return the name of the example where clause element
      */
@@ -1531,5 +1558,172 @@
 
     public void setAbatorContext(AbatorContext abatorContext) {
         this.abatorContext = abatorContext;
+    }
+
+    /**
+     * This method should return an XmlElement for the update by example
+     * statement that updates all fields in the table - but only if the field is
+     * not null in the parameter object.
+     * 
+     * @param introspectedTable
+     * @return the update element
+     */
+    protected XmlElement getUpdateByExampleSelective(IntrospectedTable introspectedTable) {
+        
+        XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getTable();
+
+        answer.addAttribute(new Attribute(
+                "id", getUpdateByExampleSelectiveStatementId())); //$NON-NLS-1$
+
+        answer.addComment();
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append("update "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
+        dynamicElement.addAttribute(new Attribute("prepend", "set")); //$NON-NLS-1$ //$NON-NLS-2$
+        answer.addElement(dynamicElement);
+
+        Iterator iter = introspectedTable.getAllColumns();
+        while (iter.hasNext()) {
+            ColumnDefinition cd = (ColumnDefinition) iter.next();
+            
+            XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+            isNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+            isNotNullElement.addAttribute(new Attribute("property", cd.getJavaProperty("record."))); //$NON-NLS-1$ //$NON-NLS-2$
+            dynamicElement.addElement(isNotNullElement);
+
+            sb.setLength(0);
+            sb.append(cd.getAliasedEscapedColumnName());
+            sb.append(" = "); //$NON-NLS-1$
+            sb.append(cd.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+            
+            isNotNullElement.addElement(new TextElement(sb.toString()));
+        }
+
+        XmlElement isParameterPresentElement =
+            new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        answer.addElement(isParameterPresentElement);
+        
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                getSqlMapNamespace(table) + "." + getExampleWhereClauseId())); //$NON-NLS-1$
+        isParameterPresentElement.addElement(includeElement);
+
+        return answer;
+    }
+
+    protected XmlElement getUpdateByExampleWithBLOBs(IntrospectedTable introspectedTable) {
+        XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getTable();
+
+        answer.addAttribute(new Attribute(
+                "id", getUpdateByExampleWithBLOBsStatementId())); //$NON-NLS-1$
+
+        answer.addComment();
+
+        StringBuffer sb = new StringBuffer();
+        sb.append("update "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        // set up for first column
+        sb.setLength(0);
+        sb.append("set "); //$NON-NLS-1$
+
+        Iterator iter = introspectedTable.getAllColumns();
+        while (iter.hasNext()) {
+            ColumnDefinition cd = (ColumnDefinition) iter.next();
+
+            sb.append(cd.getAliasedEscapedColumnName());
+            sb.append(" = "); //$NON-NLS-1$
+            sb.append(cd.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+
+            if (iter.hasNext()) {
+                sb.append(',');
+            }
+
+            answer.addElement(new TextElement(sb.toString()));
+
+            // set up for the next column
+            if (iter.hasNext()) {
+                sb.setLength(0);
+                OutputUtilities.xmlIndent(sb, 1);
+            }
+        }
+
+        XmlElement isParameterPresentElement =
+            new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        answer.addElement(isParameterPresentElement);
+        
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                getSqlMapNamespace(table) + "." + getExampleWhereClauseId())); //$NON-NLS-1$
+        isParameterPresentElement.addElement(includeElement);
+
+        return answer;
+    }
+
+    protected XmlElement getUpdateByExampleWithoutBLOBs(IntrospectedTable introspectedTable) {
+        XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getTable();
+
+        answer.addAttribute(new Attribute(
+                "id", getUpdateByExampleStatementId())); //$NON-NLS-1$
+
+        answer.addComment();
+
+        StringBuffer sb = new StringBuffer();
+        sb.append("update "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        // set up for first column
+        sb.setLength(0);
+        sb.append("set "); //$NON-NLS-1$
+
+        Iterator iter = introspectedTable.getNonBLOBColumns();
+        while (iter.hasNext()) {
+            ColumnDefinition cd = (ColumnDefinition) iter.next();
+
+            sb.append(cd.getAliasedEscapedColumnName());
+            sb.append(" = "); //$NON-NLS-1$
+            sb.append(cd.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+
+            if (iter.hasNext()) {
+                sb.append(',');
+            }
+
+            answer.addElement(new TextElement(sb.toString()));
+
+            // set up for the next column
+            if (iter.hasNext()) {
+                sb.setLength(0);
+                OutputUtilities.xmlIndent(sb, 1);
+            }
+        }
+
+        XmlElement isParameterPresentElement =
+            new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        answer.addElement(isParameterPresentElement);
+        
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                getSqlMapNamespace(table) + "." + getExampleWhereClauseId())); //$NON-NLS-1$
+        isParameterPresentElement.addElement(includeElement);
+
+        return answer;
+    }
+
+    public String getUpdateByExampleStatementId() {
+        return "abatorgenerated_updateByExample"; //$NON-NLS-1$
+    }
+
+    public String getUpdateByExampleWithBLOBsStatementId() {
+        return "abatorgenerated_updateByExampleWithBLOBs"; //$NON-NLS-1$
     }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java Mon Sep 24 19:48:38 2007
@@ -296,4 +296,19 @@
         
         return answer;
     }
+
+    protected XmlElement getUpdateByExampleSelective(IntrospectedTable introspectedTable) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
+
+    protected XmlElement getUpdateByExampleWithBLOBs(IntrospectedTable introspectedTable) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
+
+    protected XmlElement getUpdateByExampleWithoutBLOBs(IntrospectedTable introspectedTable) {
+        // this method is not supported in the legacy generator set
+        return null;
+    }
 }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java?rev=579041&r1=579040&r2=579041&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java Mon Sep 24 19:48:38 2007
@@ -1,21 +1,21 @@
 package abatortest.java2;
 
-import abatortest.java2.execute.conditional.java2.ConditionalJava2Tests;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import abatortest.java2.execute.conditional.java2.ConditionalJava2TestSuite;
 import abatortest.java2.execute.conditional.legacy.ConditionalLegacyTests;
 import abatortest.java2.execute.flat.java2.FlatJava2Tests;
 import abatortest.java2.execute.flat.legacy.FlatLegacyTests;
 import abatortest.java2.execute.hierarchical.java2.HierarchicalJava2Tests;
 import abatortest.java2.execute.hierarchical.legacy.HierarchicalLegacyTests;
 import abatortest.java2.execute.miscellaneous.MiscellaneousTests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class CompleteJava2TestSuite {
     
     public static Test suite() {
-        TestSuite suite = new TestSuite();
+        TestSuite suite = new TestSuite("All Tests");
         
-        suite.addTestSuite(ConditionalJava2Tests.class);
+        suite.addTest(ConditionalJava2TestSuite.suite());
         suite.addTestSuite(ConditionalLegacyTests.class);
         suite.addTestSuite(FlatJava2Tests.class);
         suite.addTestSuite(FlatLegacyTests.class);