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/08/28 06:06:03 UTC

svn commit: r570300 [1/2] - in /ibatis/trunk/java/mapper/mapper2/tools/abator/core: build/ src/org/apache/ibatis/abator/ant/ src/org/apache/ibatis/abator/api/ src/org/apache/ibatis/abator/config/ src/org/apache/ibatis/abator/config/xml/ src/org/apache/...

Author: jgbutler
Date: Mon Aug 27 21:06:02 2007
New Revision: 570300

URL: http://svn.apache.org/viewvc?rev=570300&view=rev
Log:
Abator: Code and Tests for countByExample support

Added:
    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
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java
    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/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/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/execute/conditional/java2/ConditionalJava2Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/legacy/ConditionalLegacyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java2/ConditionalJava2Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java5/ConditionalJava5Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/legacy/ConditionalLegacyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/flat/java2/FlatJava2Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/flat/java5/FlatJava5Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/flat/legacy/FlatLegacyTests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/hierarchical/java2/HierarchicalJava2Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/hierarchical/java5/HierarchicalJava5Tests.java
    ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/hierarchical/legacy/HierarchicalLegacyTests.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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -1,4 +1,4 @@
 #Abator build version info
-#Tue Aug 21 21:49:49 CDT 2007
+#Mon Aug 27 23:02:40 CDT 2007
 version=1.1.0
-buildNum=365
+buildNum=374

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java Mon Aug 27 21:06:02 2007
@@ -103,7 +103,7 @@
         
         Set fullyqualifiedTables = new HashSet();
         if (StringUtility.stringHasValue(fullyQualifiedTableNames)) {
-            StringTokenizer st = new StringTokenizer(fullyQualifiedTableNames, ",");
+            StringTokenizer st = new StringTokenizer(fullyQualifiedTableNames, ","); //$NON-NLS-1$
             while (st.hasMoreTokens()) {
                 String s = st.nextToken().trim();
                 if (s.length() > 0) {
@@ -112,9 +112,9 @@
             }
         }
         
-        List contexts = new ArrayList();
+        Set contexts = new HashSet();
         if (StringUtility.stringHasValue(contextIds)) {
-            StringTokenizer st = new StringTokenizer(contextIds, ",");
+            StringTokenizer st = new StringTokenizer(contextIds, ","); //$NON-NLS-1$
             while (st.hasMoreTokens()) {
                 String s = st.nextToken().trim();
                 if (s.length() > 0) {

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java Mon Aug 27 21:06:02 2007
@@ -131,7 +131,7 @@
      * 
      * @param callback an instance of the ProgressCallback interface, or <code>null</code>
      *   if you do not require progress information
-     * @param contextIds a list of Strings containing context ids to run.  Only the
+     * @param contextIds a set of Strings containing context ids to run.  Only the
      *   contexts with an id specified in this list will be run.  If the list is
      *   null or empty, than all contexts are run.
      * @throws InvalidConfigurationException
@@ -139,7 +139,7 @@
      * @throws IOException
      * @throws InterruptedException if the method is cancelled through the ProgressCallback
      */
-    public void generate(ProgressCallback callback, List contextIds)
+    public void generate(ProgressCallback callback, Set contextIds)
             throws SQLException, IOException, InterruptedException {
         generate(callback, contextIds, null);
     }
@@ -151,7 +151,7 @@
      * 
      * @param callback an instance of the ProgressCallback interface, or <code>null</code>
      *   if you do not require progress information
-     * @param contextIds a list of Strings containing context ids to run.  Only the
+     * @param contextIds a set of Strings containing context ids to run.  Only the
      *   contexts with an id specified in this list will be run.  If the list is
      *   null or empty, than all contexts are run.
      * @param fullyQualifiedTableNames a set of table names to generate.  The elements
@@ -165,7 +165,7 @@
      * @throws IOException
      * @throws InterruptedException if the method is cancelled through the ProgressCallback
      */
-    public void generate(ProgressCallback callback, List contextIds, Set fullyQualifiedTableNames)
+    public void generate(ProgressCallback callback, Set contextIds, Set fullyQualifiedTableNames)
             throws SQLException, IOException, InterruptedException {
 
         if (callback == null) {
@@ -181,10 +181,10 @@
             contextsToRun = abatorConfiguration.getAbatorContexts();
         } else {
             contextsToRun = new ArrayList();
-            Iterator iter = contextIds.iterator();
+            Iterator iter = abatorConfiguration.getAbatorContexts().iterator();
             while (iter.hasNext()) {
-                AbatorContext abatorContext = abatorConfiguration.getAbatorContext((String) iter.next());
-                if (abatorContext != null) {
+                AbatorContext abatorContext = (AbatorContext) iter.next();
+                if (contextIds.contains(abatorContext.getId())) {
                     contextsToRun.add(abatorContext);
                 }
             }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java Mon Aug 27 21:06:02 2007
@@ -49,6 +49,11 @@
 	public static void main(String[] args) {
         Map arguments = parseCommandLine(args);
         
+        if (!arguments.containsKey(CONFIG_FILE)) {
+            writeLine(Messages.getString("RuntimeError.0")); //$NON-NLS-1$
+            return;
+        }
+        
         List warnings = new ArrayList();
 
         String configfile = (String) arguments.get(CONFIG_FILE);
@@ -60,7 +65,7 @@
 
         Set fullyqualifiedTables = new HashSet();
         if (arguments.containsKey(TABLES)) {
-            StringTokenizer st = new StringTokenizer((String)arguments.get(TABLES), ",");
+            StringTokenizer st = new StringTokenizer((String)arguments.get(TABLES), ","); //$NON-NLS-1$
             while (st.hasMoreTokens()) {
                 String s = st.nextToken().trim();
                 if (s.length() > 0) {
@@ -69,9 +74,9 @@
             }
         }
         
-        List contexts = new ArrayList();
+        Set contexts = new HashSet();
         if (arguments.containsKey(CONTEXT_IDS)) {
-            StringTokenizer st = new StringTokenizer((String)arguments.get(CONTEXT_IDS), ",");
+            StringTokenizer st = new StringTokenizer((String)arguments.get(CONTEXT_IDS), ","); //$NON-NLS-1$
             while (st.hasMoreTokens()) {
                 String s = st.nextToken().trim();
                 if (s.length() > 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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -101,4 +101,12 @@
      * @return the calculated name
      */
     String getDeleteByExampleMethodName(IntrospectedTable introspectedTable);
+
+    /**
+     * Calculates and returns a name for the count by example method.
+     * 
+     * @param introspectedTable
+     * @return the calculated name
+     */
+    String getCountByExampleMethodName(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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -87,6 +87,8 @@
     String getSelectByExampleStatementId();
 
     String getSelectByExampleWithBLOBsStatementId();
+    
+    String getCountByExampleStatementId();
 
     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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -43,7 +43,9 @@
 	private boolean deleteByPrimaryKeyStatementEnabled;
 
 	private boolean deleteByExampleStatementEnabled;
-
+    
+    private boolean countByExampleStatementEnabled;
+    
 	private List columnOverrides;
 
 	private Map ignoredColumns;
@@ -78,6 +80,7 @@
 		updateByPrimaryKeyStatementEnabled = true;
 		deleteByPrimaryKeyStatementEnabled = true;
 		deleteByExampleStatementEnabled = true;
+        countByExampleStatementEnabled = true;
 	}
 
 	public boolean isDeleteByPrimaryKeyStatementEnabled() {
@@ -374,6 +377,10 @@
             xmlElement.addAttribute(new Attribute("enableDeleteByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
         }
 
+        if (!countByExampleStatementEnabled) {
+            xmlElement.addAttribute(new Attribute("enableCountByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
         if (StringUtility.stringHasValue(selectByPrimaryKeyQueryId)) {
             xmlElement.addAttribute(new Attribute("selectByPrimaryKeyQueryId", selectByPrimaryKeyQueryId)); //$NON-NLS-1$
         }
@@ -425,5 +432,14 @@
 
     public void setDelimitIdentifiers(boolean delimitIdentifiers) {
         this.delimitIdentifiers = delimitIdentifiers;
+    }
+
+    public boolean isCountByExampleStatementEnabled() {
+        return countByExampleStatementEnabled;
+    }
+
+    public void setCountByExampleStatementEnabled(
+            boolean countByExampleStatementEnabled) {
+        this.countByExampleStatementEnabled = countByExampleStatementEnabled;
     }
 }

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -323,6 +323,8 @@
                 .getProperty("enableDeleteByPrimaryKey"); //$NON-NLS-1$
         String enableDeleteByExample = attributes
                 .getProperty("enableDeleteByExample"); //$NON-NLS-1$
+        String enableCountByExample = attributes
+            .getProperty("enableCountByExample"); //$NON-NLS-1$
         String selectByPrimaryKeyQueryId = attributes
                 .getProperty("selectByPrimaryKeyQueryId"); //$NON-NLS-1$
         String selectByExampleQueryId = attributes
@@ -379,6 +381,11 @@
         if (StringUtility.stringHasValue(enableDeleteByExample)) {
             tc.setDeleteByExampleStatementEnabled("true" //$NON-NLS-1$
                     .equals(enableDeleteByExample));
+        }
+
+        if (StringUtility.stringHasValue(enableCountByExample)) {
+            tc.setCountByExampleStatementEnabled("true" //$NON-NLS-1$
+                    .equals(enableCountByExample));
         }
 
         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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -146,6 +146,7 @@
   enableUpdateByPrimaryKey CDATA #IMPLIED
   enableDeleteByPrimaryKey CDATA #IMPLIED
   enableDeleteByExample CDATA #IMPLIED
+  enableCountByExample 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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -122,4 +122,9 @@
     public String getUpdateByPrimaryKeySelectiveMethodName(IntrospectedTable introspectedTable) {
         return "updateByPrimaryKeySelective"; //$NON-NLS-1$
     }
+
+    public String getCountByExampleMethodName(IntrospectedTable introspectedTable) {
+        return "countByExample"; //$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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -170,4 +170,14 @@
         
         return sb.toString();
     }
+
+    public String getCountByExampleMethodName(IntrospectedTable introspectedTable) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("count"); //$NON-NLS-1$
+        sb.append(introspectedTable.getTable().getDomainObjectName());
+        sb.append("ByExample"); //$NON-NLS-1$
+        
+        return sb.toString();
+    }
+
 }

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -358,6 +358,16 @@
             }
         }
 
+        if (introspectedTable.getRules().generateCountByExample()) {
+            methods = getCountByExampleMethods(introspectedTable, false, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
         afterImplementationGenerationHook(introspectedTable, answer);
         
         return answer;
@@ -499,6 +509,16 @@
             }
         }
 
+        if (introspectedTable.getRules().generateCountByExample()) {
+            methods = getCountByExampleMethods(introspectedTable, true, answer);
+            if (methods != null) {
+                iter = methods.iterator();
+                while (iter.hasNext()) {
+                    answer.addMethod((Method) iter.next());
+                }
+            }
+        }
+        
         afterInterfaceGenerationHook(introspectedTable, answer);
         
         return answer;
@@ -1098,6 +1118,50 @@
                     .getDeleteByPrimaryKeyStatementId(), "key")); //$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 getCountByExampleMethods(
+            IntrospectedTable introspectedTable, boolean interfaceMethod,
+            CompilationUnit compilationUnit) {
+
+        if (interfaceMethod && exampleMethodVisibility != JavaVisibility.PUBLIC) {
+            return null;
+        }
+        
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+        compilationUnit.addImportedType(type);
+
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(exampleMethodVisibility);
+        method.setReturnType(PrimitiveTypeWrapper.getIntegerInstance());
+        method.setName(methodNameCalculator.getCountByExampleMethodName(introspectedTable));
+        method.addParameter(new Parameter(type, "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
+            StringBuffer sb = new StringBuffer();
+
+            sb.append("Integer count = (Integer)  "); //$NON-NLS-1$
+            sb.append(daoTemplate.getQueryForObjectMethod(sqlMapGenerator
+                    .getSqlMapNamespace(table), sqlMapGenerator
+                    .getCountByExampleStatementId(), "example")); //$NON-NLS-1$
+            method.addBodyLine(sb.toString());
+            method.addBodyLine("return count;"); //$NON-NLS-1$
         }
 
         ArrayList answer = new ArrayList();

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -28,6 +28,7 @@
 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;
+import org.apache.ibatis.abator.api.dom.java.PrimitiveTypeWrapper;
 import org.apache.ibatis.abator.api.dom.java.TopLevelClass;
 import org.apache.ibatis.abator.internal.db.ColumnDefinition;
 import org.apache.ibatis.abator.internal.sqlmap.ExampleClause;
@@ -236,6 +237,52 @@
             method.addBodyLine(sb.toString());
             
             method.addBodyLine("return rows;"); //$NON-NLS-1$
+        }
+
+        ArrayList answer = new ArrayList();
+        answer.add(method);
+
+        return answer;
+    }
+
+    protected List getCountByExampleMethods(
+            IntrospectedTable introspectedTable,
+            boolean interfaceMethod,
+            CompilationUnit compilationUnit) {
+
+        if (interfaceMethod && exampleMethodVisibility != JavaVisibility.PUBLIC) {
+            return null;
+        }
+        
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+        compilationUnit.addImportedType(type);
+
+        Method method = new Method();
+        method.addComment(table);
+        method.setVisibility(exampleMethodVisibility);
+        method.setReturnType(PrimitiveTypeWrapper.getIntegerInstance());
+        method.setName(methodNameCalculator.getCountByExampleMethodName(introspectedTable));
+        method.addParameter(new Parameter(type, "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
+            StringBuffer sb = new StringBuffer();
+
+            sb.append("Integer count = (Integer) "); //$NON-NLS-1$
+            sb.append(daoTemplate.getQueryForObjectMethod(sqlMapGenerator.getSqlMapNamespace(table),
+                    sqlMapGenerator.getCountByExampleStatementId(),
+                    "getExampleParms(example)")); //$NON-NLS-1$
+            method.addBodyLine(sb.toString());
+            
+            method.addBodyLine("return count;"); //$NON-NLS-1$
         }
 
         ArrayList answer = new ArrayList();

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -189,14 +189,15 @@
     
     /**
      * Implements the rule for generating the SQL example where clause element.
-     * Generate the element if either the selectByExample or deleteByExample
-     * statement is allowed.
+     * Generate the element if the selectByExample or deleteByExample
+     * or countByExample statements are allowed.
      * 
      * @return true if the SQL where clause element should be generated
      */
     public boolean generateSQLExampleWhereClause() {
         boolean rc = tableConfiguration.isSelectByExampleStatementEnabled()
-            || tableConfiguration.isDeleteByExampleStatementEnabled();
+            || tableConfiguration.isDeleteByExampleStatementEnabled()
+            || tableConfiguration.isCountByExampleStatementEnabled();
         
         return rc;
     }
@@ -245,16 +246,23 @@
     }
 
     /**
-     * Implements the rule for generating an example class with no super class.
-     * The class should only be generated if the selectByExample or
-     * deleteByExample methods are allowed.
+     * Implements the rule for generating an example class.
+     * The class should be generated if the selectByExample or
+     * deleteByExample or countByExample methods are allowed.
      * 
      * @return true if the example class should be generated
      */
     public boolean generateExampleClass() {
         boolean rc = tableConfiguration.isSelectByExampleStatementEnabled()
-                || tableConfiguration.isDeleteByExampleStatementEnabled();
+                || tableConfiguration.isDeleteByExampleStatementEnabled()
+                || tableConfiguration.isCountByExampleStatementEnabled();
     
+        return rc;
+    }
+    
+    public boolean generateCountByExample() {
+        boolean rc = tableConfiguration.isCountByExampleStatementEnabled();
+
         return rc;
     }
 

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -256,6 +256,13 @@
             }
         }
         
+        if (introspectedTable.getRules().generateCountByExample()) {
+            element = getCountByExample(introspectedTable);
+            if (element != null) {
+                answer.addElement(element);
+            }
+        }
+        
         return answer;
     }
 
@@ -729,6 +736,48 @@
     }
 
     /**
+     * This method should return an XmlElement for the count by example
+     * statement. This statement uses the "by example" SQL fragment
+     * 
+     * @param introspectedTable
+     * @return the count by example element
+     */
+    protected XmlElement getCountByExample(IntrospectedTable introspectedTable) {
+
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getTable();
+        FullyQualifiedJavaType fqjt = javaModelGenerator.getExampleType(table);
+
+        answer
+                .addAttribute(new Attribute(
+                        "id", getCountByExampleStatementId())); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "parameterClass", fqjt.getFullyQualifiedName())); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "resultClass", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$
+
+        answer.addComment();
+
+        StringBuffer sb = new StringBuffer();
+        sb.append("select count(*) from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        sb.setLength(0);
+        sb.append(getSqlMapNamespace(table));
+        sb.append('.');
+        sb.append(getExampleWhereClauseId());
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                sb.toString()));
+
+        answer.addElement(includeElement);
+
+        return answer;
+    }
+    
+    /**
      * This method should return an XmlElement for the select by primary key
      * statement. The statement should include all fields in the table,
      * including BLOB fields.
@@ -936,6 +985,14 @@
         return "abatorgenerated_deleteByExample"; //$NON-NLS-1$
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.ibatis.abator.api.SqlMapGenerator#getCountByExampleStatementId()
+     */
+    public String getCountByExampleStatementId() {
+        return "abatorgenerated_countByExample"; //$NON-NLS-1$
+    }
+    
     /*
      * (non-Javadoc)
      * 

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=570300&r1=570299&r2=570300&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 Aug 27 21:06:02 2007
@@ -79,6 +79,42 @@
     }
 
     /**
+     * This method should return an XmlElement for the count by example
+     * statement. This statement uses the "by example" SQL fragment
+     * 
+     * @param introspectedTable
+     * @return the select element
+     */
+    protected XmlElement getCountByExample(IntrospectedTable introspectedTable) {
+
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getTable();
+        answer.addAttribute(new Attribute("id", getCountByExampleStatementId())); //$NON-NLS-1$
+        answer.addAttribute(new Attribute("parameterClass", "java.util.Map")); //$NON-NLS-1$ //$NON-NLS-2$
+        answer.addAttribute(new Attribute("resultClass", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$
+
+        answer.addComment();
+
+        StringBuffer sb = new StringBuffer();
+        sb.append("select count(*) from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        sb.setLength(0);
+        sb.append(getSqlMapNamespace(table));
+        sb.append('.');
+        sb.append(getExampleWhereClauseId());
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                sb.toString()));
+        
+        answer.addElement(includeElement);
+
+        return answer;
+    }
+
+    /**
      * This method should return an XmlElement for the example where clause
      * SQL fragment (an sql fragment).
      * 

Added: 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=570300&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/CompleteJava2TestSuite.java Mon Aug 27 21:06:02 2007
@@ -0,0 +1,29 @@
+package abatortest.java2;
+
+import abatortest.java2.execute.conditional.java2.ConditionalJava2Tests;
+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();
+        
+        suite.addTestSuite(ConditionalJava2Tests.class);
+        suite.addTestSuite(ConditionalLegacyTests.class);
+        suite.addTestSuite(FlatJava2Tests.class);
+        suite.addTestSuite(FlatLegacyTests.class);
+        suite.addTestSuite(HierarchicalJava2Tests.class);
+        suite.addTestSuite(HierarchicalLegacyTests.class);
+        suite.addTestSuite(MiscellaneousTests.class);
+        
+        return suite;
+    }
+
+}

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/java2/ConditionalJava2Tests.java Mon Aug 27 21:06:02 2007
@@ -199,6 +199,42 @@
         }
     }
 
+    public void testFieldsOnlyCountByExample() {
+        FieldsonlyDAO dao = new FieldsonlyDAOImpl(sqlMapClient);
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(new Double(11.22));
+            record.setFloatfield(new Double(33.44));
+            record.setIntegerfield(new Integer(5));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(44.55));
+            record.setFloatfield(new Double(66.77));
+            record.setIntegerfield(new Integer(8));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(88.99));
+            record.setFloatfield(new Double(100.111));
+            record.setIntegerfield(new Integer(9));
+            dao.insert(record);
+
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldGreaterThan(new Integer(5));
+
+            Integer rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKOnlyInsert() {
         PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
 
@@ -339,6 +375,38 @@
         }
     }
 
+    public void testPKOnlyCountByExample() {
+        PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(new Integer(1));
+            key.setSeqNum(new Integer(3));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(5));
+            key.setSeqNum(new Integer(6));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(7));
+            key.setSeqNum(new Integer(8));
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.createCriteria().andIdGreaterThan(new Integer(4));
+            Integer rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsInsert() {
         PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
 
@@ -1020,6 +1088,38 @@
         }
     }
 
+    public void testPKFieldsCountByExample() {
+        PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+
+            dao.insert(record);
+
+            PkfieldsExample example = new PkfieldsExample();
+            example.createCriteria().andLastnameLike("J%");
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKBlobsInsert() {
         PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
 
@@ -1271,6 +1371,35 @@
         }
     }
 
+    public void testPKBlobsCountByExample() {
+        PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkblobs();
+            record.setId(new Integer(6));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdLessThan(new Integer(4));
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsBlobsInsert() {
         PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
 
@@ -1621,6 +1750,39 @@
         }
     }
 
+    public void testPKFieldsBlobsCountByExample() {
+        PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkfieldsblobs();
+            record.setId1(new Integer(5));
+            record.setId2(new Integer(6));
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1NotEqualTo(new Integer(3));
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testFieldsBlobsInsert() {
         FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
 
@@ -1777,6 +1939,37 @@
         }
     }
 
+    public void testFieldsBlobsCountByExample() {
+        FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testAwfulTableInsert() {
         AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
 
@@ -2794,6 +2987,57 @@
             assertEquals(11, returnedRecord.getId1().intValue());
             returnedRecord = (AwfulTable) answer.get(5);
             assertEquals(1, returnedRecord.getId1().intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableCountByExample() {
+        AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
+
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+
+            dao.insert(record);
+
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(new Integer(11));
+            record.setId2(new Integer(22));
+            record.setId5(new Integer(55));
+            record.setId6(new Integer(66));
+            record.setId7(new Integer(77));
+            record.setSecondCustomerId(new Integer(567567));
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+
+            dao.insert(record);
+
+            AwfulTableExample example = new AwfulTableExample();
+            example.createCriteria().andEMailLike("fred@%");
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/legacy/ConditionalLegacyTests.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/legacy/ConditionalLegacyTests.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/legacy/ConditionalLegacyTests.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava2/abatortest/java2/execute/conditional/legacy/ConditionalLegacyTests.java Mon Aug 27 21:06:02 2007
@@ -171,6 +171,44 @@
         }
     }
 
+    public void testFieldsOnlyCountByExample() {
+        FieldsonlyDAO dao = new FieldsonlyDAOImpl(sqlMapClient);
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(new Double(11.22));
+            record.setFloatfield(new Double(33.44));
+            record.setIntegerfield(new Integer(5));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(44.55));
+            record.setFloatfield(new Double(66.77));
+            record.setIntegerfield(new Integer(8));
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(new Double(88.99));
+            record.setFloatfield(new Double(100.111));
+            record.setIntegerfield(new Integer(9));
+            dao.insert(record);
+
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.setIntegerfield(new Integer(5));
+            example
+                    .setIntegerfield_Indicator(FieldsonlyExample.EXAMPLE_GREATER_THAN);
+
+            Integer rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+
+            example = new FieldsonlyExample();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKOnlyInsert() {
         PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
 
@@ -285,6 +323,39 @@
         }
     }
 
+    public void testPKOnlyCountByExample() {
+        PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(new Integer(1));
+            key.setSeqNum(new Integer(3));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(5));
+            key.setSeqNum(new Integer(6));
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(new Integer(7));
+            key.setSeqNum(new Integer(8));
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.setId(new Integer(4));
+            example.setId_Indicator(PkonlyExample.EXAMPLE_GREATER_THAN);
+            Integer rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+
+            example = new PkonlyExample();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsInsert() {
         PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
 
@@ -619,6 +690,39 @@
         }
     }
 
+    public void testPKFieldsCountByExample() {
+        PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+
+            dao.insert(record);
+
+            PkfieldsExample example = new PkfieldsExample();
+            example.setLastname("J%");
+            example.setLastname_Indicator(PkfieldsExample.EXAMPLE_LIKE);
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example = new PkfieldsExample();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKBlobsInsert() {
         PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
 
@@ -848,6 +952,36 @@
         }
     }
 
+    public void testPKBlobsCountByExample() {
+        PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(new Integer(3));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkblobs();
+            record.setId(new Integer(6));
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            PkblobsExample example = new PkblobsExample();
+            example.setId(new Integer(4));
+            example.setId_Indicator(PkblobsExample.EXAMPLE_LESS_THAN);
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example = new PkblobsExample();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsBlobsInsert() {
         PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
 
@@ -1172,6 +1306,40 @@
         }
     }
 
+    public void testPKFieldsBlobsCountByExample() {
+        PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(new Integer(3));
+            record.setId2(new Integer(4));
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkfieldsblobs();
+            record.setId1(new Integer(5));
+            record.setId2(new Integer(6));
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.setId1(new Integer(3));
+            example.setId1_Indicator(PkfieldsblobsExample.EXAMPLE_NOT_EQUALS);
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example = new PkfieldsblobsExample();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testFieldsBlobsInsert() {
         FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
 
@@ -1304,6 +1472,38 @@
         }
     }
 
+    public void testFieldsBlobsCountByExample() {
+        FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.setFirstname("S%");
+            example.setFirstname_Indicator(FieldsblobsExample.EXAMPLE_LIKE);
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example = new FieldsblobsExample();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testAwfulTableInsert() {
         AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
 
@@ -1973,6 +2173,58 @@
             assertEquals(11, returnedRecord.getId1().intValue());
             returnedRecord = (AwfulTable) answer.get(5);
             assertEquals(1, returnedRecord.getId1().intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableCountByExample() {
+        AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
+
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(new Integer(1));
+            record.setId2(new Integer(2));
+            record.setId5(new Integer(5));
+            record.setId6(new Integer(6));
+            record.setId7(new Integer(7));
+            record.setSecondCustomerId(new Integer(567));
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+
+            dao.insert(record);
+
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(new Integer(11));
+            record.setId2(new Integer(22));
+            record.setId5(new Integer(55));
+            record.setId6(new Integer(66));
+            record.setId7(new Integer(77));
+            record.setSecondCustomerId(new Integer(567567));
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+
+            dao.insert(record);
+
+            AwfulTableExample example = new AwfulTableExample();
+            example.seteMail("fred@%");
+            example.seteMail_Indicator(AwfulTableExample.EXAMPLE_LIKE);
+            Integer rows = dao.countByExample(example);
+            assertEquals(1, rows.intValue());
+
+            example = new AwfulTableExample();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows.intValue());
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java2/ConditionalJava2Tests.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java2/ConditionalJava2Tests.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java2/ConditionalJava2Tests.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java2/ConditionalJava2Tests.java Mon Aug 27 21:06:02 2007
@@ -198,6 +198,41 @@
         }
     }
 
+    public void testFieldsOnlyCountByExample() {
+        FieldsonlyDAO dao = new FieldsonlyDAOImpl(sqlMapClient);
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(11.22);
+            record.setFloatfield(33.44);
+            record.setIntegerfield(5);
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(44.55);
+            record.setFloatfield(66.77);
+            record.setIntegerfield(8);
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(88.99);
+            record.setFloatfield(100.111);
+            record.setIntegerfield(9);
+            dao.insert(record);
+
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldGreaterThan(5);
+            int rows = dao.countByExample(example);
+            assertEquals(2, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+    
     public void testPKOnlyInsert() {
         PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
 
@@ -338,6 +373,38 @@
         }
     }
 
+    public void testPKOnlyCountByExample() {
+        PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(1);
+            key.setSeqNum(3);
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(5);
+            key.setSeqNum(6);
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(7);
+            key.setSeqNum(8);
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.createCriteria().andIdGreaterThan(4);
+            int rows = dao.countByExample(example);
+            assertEquals(2, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsInsert() {
         PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
 
@@ -1017,6 +1084,38 @@
         }
     }
 
+    public void testPKFieldsCountByExample() {
+        PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(1);
+            record.setId2(2);
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(3);
+            record.setId2(4);
+
+            dao.insert(record);
+
+            PkfieldsExample example = new PkfieldsExample();
+            example.createCriteria().andLastnameLike("J%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKBlobsInsert() {
         PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
 
@@ -1268,6 +1367,35 @@
         }
     }
 
+    public void testPKBlobsCountByExample() {
+        PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(3);
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkblobs();
+            record.setId(6);
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdLessThan(4);
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsBlobsInsert() {
         PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
 
@@ -1618,6 +1746,39 @@
         }
     }
 
+    public void testPKFieldsBlobsCountByExample() {
+        PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(3);
+            record.setId2(4);
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkfieldsblobs();
+            record.setId1(5);
+            record.setId2(6);
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1NotEqualTo(3);
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testFieldsBlobsInsert() {
         FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
 
@@ -1774,6 +1935,37 @@
         }
     }
 
+    public void testFieldsBlobsCountByExample() {
+        FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testAwfulTableInsert() {
         AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
 
@@ -2791,6 +2983,57 @@
             assertEquals(11, returnedRecord.getId1().intValue());
             returnedRecord = (AwfulTable) answer.get(5);
             assertEquals(1, returnedRecord.getId1().intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableCountByExample() {
+        AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
+
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(1);
+            record.setId2(2);
+            record.setId5(5);
+            record.setId6(6);
+            record.setId7(7);
+            record.setSecondCustomerId(567);
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+
+            dao.insert(record);
+
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(11);
+            record.setId2(22);
+            record.setId5(55);
+            record.setId6(66);
+            record.setId7(77);
+            record.setSecondCustomerId(567567);
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+
+            dao.insert(record);
+
+            AwfulTableExample example = new AwfulTableExample();
+            example.createCriteria().andEMailLike("fred@%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java5/ConditionalJava5Tests.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java5/ConditionalJava5Tests.java?rev=570300&r1=570299&r2=570300&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java5/ConditionalJava5Tests.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/execute/conditional/java5/ConditionalJava5Tests.java Mon Aug 27 21:06:02 2007
@@ -198,6 +198,41 @@
         }
     }
 
+    public void testFieldsOnlyCountByExample() {
+        FieldsonlyDAO dao = new FieldsonlyDAOImpl(sqlMapClient);
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(11.22);
+            record.setFloatfield(33.44);
+            record.setIntegerfield(5);
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(44.55);
+            record.setFloatfield(66.77);
+            record.setIntegerfield(8);
+            dao.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(88.99);
+            record.setFloatfield(100.111);
+            record.setIntegerfield(9);
+            dao.insert(record);
+
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldGreaterThan(5);
+            int rows = dao.countByExample(example);
+            assertEquals(2, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKOnlyInsert() {
         PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
 
@@ -338,6 +373,38 @@
         }
     }
 
+    public void testPKOnlyCountByExample() {
+        PkonlyDAO dao = new PkonlyDAOImpl(sqlMapClient);
+
+        try {
+            PkonlyKey key = new PkonlyKey();
+            key.setId(1);
+            key.setSeqNum(3);
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(5);
+            key.setSeqNum(6);
+            dao.insert(key);
+
+            key = new PkonlyKey();
+            key.setId(7);
+            key.setSeqNum(8);
+            dao.insert(key);
+
+            PkonlyExample example = new PkonlyExample();
+            example.createCriteria().andIdGreaterThan(4);
+            int rows = dao.countByExample(example);
+            assertEquals(2, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(3, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsInsert() {
         PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
 
@@ -1017,6 +1084,37 @@
         }
     }
 
+    public void testPKFieldsCountByExample() {
+        PkfieldsDAO dao = new PkfieldsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfields record = new Pkfields();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setId1(1);
+            record.setId2(2);
+            dao.insert(record);
+
+            record = new Pkfields();
+            record.setFirstname("Bob");
+            record.setLastname("Jones");
+            record.setId1(3);
+            record.setId2(4);
+            dao.insert(record);
+
+            PkfieldsExample example = new PkfieldsExample();
+            example.createCriteria().andLastnameLike("J%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKBlobsInsert() {
         PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
 
@@ -1269,6 +1367,35 @@
         }
     }
 
+    public void testPKBlobsCountByExample() {
+        PkblobsDAO dao = new PkblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkblobs record = new Pkblobs();
+            record.setId(3);
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkblobs();
+            record.setId(6);
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            PkblobsExample example = new PkblobsExample();
+            example.createCriteria().andIdLessThan(4);
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testPKFieldsBlobsInsert() {
         PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
 
@@ -1623,6 +1750,39 @@
         }
     }
 
+    public void testPKFieldsBlobsCountByExample() {
+        PkfieldsblobsDAO dao = new PkfieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            Pkfieldsblobs record = new Pkfieldsblobs();
+            record.setId1(3);
+            record.setId2(4);
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            record = new Pkfieldsblobs();
+            record.setId1(5);
+            record.setId2(6);
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            dao.insert(record);
+
+            PkfieldsblobsExample example = new PkfieldsblobsExample();
+            example.createCriteria().andId1NotEqualTo(3);
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testFieldsBlobsInsert() {
         FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
 
@@ -1779,6 +1939,37 @@
         }
     }
 
+    public void testFieldsBlobsCountByExample() {
+        FieldsblobsDAO dao = new FieldsblobsDAOImpl(sqlMapClient);
+
+        try {
+            FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Jeff");
+            record.setLastname("Smith");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            record = new FieldsblobsWithBLOBs();
+            record.setFirstname("Scott");
+            record.setLastname("Jones");
+            record.setBlob1(generateRandomBlob());
+            record.setBlob2(generateRandomBlob());
+            dao.insert(record);
+
+            FieldsblobsExample example = new FieldsblobsExample();
+            example.createCriteria().andFirstnameLike("S%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
     public void testAwfulTableInsert() {
         AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
 
@@ -2796,6 +2987,57 @@
             assertEquals(11, returnedRecord.getId1().intValue());
             returnedRecord = answer.get(5);
             assertEquals(1, returnedRecord.getId1().intValue());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAwfulTableCountByExample() {
+        AwfulTableDAO dao = new AwfulTableDAOImpl(sqlMapClient);
+
+        try {
+            AwfulTable record = new AwfulTable();
+            record.seteMail("fred@fred.com");
+            record.setEmailaddress("alsofred@fred.com");
+            record.setFirstFirstName("fred1");
+            record.setFourthFirstName("fred4");
+            record.setFrom("from field");
+            record.setId1(1);
+            record.setId2(2);
+            record.setId5(5);
+            record.setId6(6);
+            record.setId7(7);
+            record.setSecondCustomerId(567);
+            record.setSecondFirstName("fred2");
+            record.setThirdFirstName("fred3");
+
+            dao.insert(record);
+
+            record = new AwfulTable();
+            record.seteMail("fred2@fred.com");
+            record.setEmailaddress("alsofred2@fred.com");
+            record.setFirstFirstName("fred11");
+            record.setFourthFirstName("fred44");
+            record.setFrom("from from field");
+            record.setId1(11);
+            record.setId2(22);
+            record.setId5(55);
+            record.setId6(66);
+            record.setId7(77);
+            record.setSecondCustomerId(567567);
+            record.setSecondFirstName("fred22");
+            record.setThirdFirstName("fred33");
+
+            dao.insert(record);
+
+            AwfulTableExample example = new AwfulTableExample();
+            example.createCriteria().andEMailLike("fred@%");
+            int rows = dao.countByExample(example);
+            assertEquals(1, rows);
+
+            example.clear();
+            rows = dao.countByExample(example);
+            assertEquals(2, rows);
         } catch (SQLException e) {
             fail(e.getMessage());
         }