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 2010/01/05 17:36:06 UTC

svn commit: r896120 - in /ibatis/java/ibator/trunk/core: ibator-core/doc/ ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ ibator-core/src/...

Author: jgbutler
Date: Tue Jan  5 16:36:05 2010
New Revision: 896120

URL: http://svn.apache.org/viewvc?rev=896120&view=rev
Log:
[ibator] add support for "distinct" on selectByExample methods

Modified:
    ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt
    ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ExampleGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/model/ExampleGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java
    ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java
    ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/FlatJava2Test.java
    ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java2/FlatJava2Test.java
    ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java
    ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java

Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/ReleaseNotes.txt Tue Jan  5 16:36:05 2010
@@ -38,6 +38,7 @@
 15. Many refactorings to make way for iBATIS3
 16. IBATIS-605 - Added Informix Dialect
 17. Added ability to set annotations on method parameters
+18. Addedd support for "distinct" on select by example methods
 
 -------------------------------------------------------------------------------
 Version 1.2.1:

Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt Tue Jan  5 16:36:05 2010
@@ -5,6 +5,8 @@
     1. Add a way to override default types in the JavaTypeResolver
     2. Document change to JavaTypeResolver interface in release notes
     3. Document attributes
+    4. <tableSet> - to allow specification of common attributes for a set of
+       tables
 
 
   Future

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ExampleGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ExampleGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ExampleGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/model/ExampleGenerator.java Tue Jan  5 16:36:05 2010
@@ -124,6 +124,31 @@
         commentGenerator.addGeneralMethodComment(method, introspectedTable);
         topLevelClass.addMethod(method);
 
+        // add field, getter, setter for distinct
+        field = new Field();
+        field.setVisibility(JavaVisibility.PROTECTED);
+        field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
+        field.setName("distinct"); //$NON-NLS-1$
+        commentGenerator.addFieldComment(field, introspectedTable);
+        topLevelClass.addField(field);
+
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setName("setDistinct"); //$NON-NLS-1$
+        method.addParameter(new Parameter(FullyQualifiedJavaType
+                .getBooleanPrimitiveInstance(), "distinct")); //$NON-NLS-1$
+        method.addBodyLine("this.distinct = distinct;"); //$NON-NLS-1$
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
+        method.setName("isDistinct"); //$NON-NLS-1$
+        method.addBodyLine("return distinct;"); //$NON-NLS-1$
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+
         // add field and methods for the list of ored criteria
         field = new Field();
         field.setVisibility(JavaVisibility.PROTECTED);
@@ -195,6 +220,8 @@
         method.setVisibility(JavaVisibility.PUBLIC);
         method.setName("clear"); //$NON-NLS-1$
         method.addBodyLine("oredCriteria.clear();"); //$NON-NLS-1$
+        method.addBodyLine("orderByClause = null;"); //$NON-NLS-1$
+        method.addBodyLine("distinct = false;"); //$NON-NLS-1$
         commentGenerator.addGeneralMethodComment(method, introspectedTable);
         topLevelClass.addMethod(method);
 

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java Tue Jan  5 16:36:05 2010
@@ -44,15 +44,23 @@
 
         ibatorContext.getCommentGenerator().addComment(answer);
 
-        StringBuilder sb = new StringBuilder();
-        sb.append("select "); //$NON-NLS-1$
+        answer.addElement(new TextElement("select")); //$NON-NLS-1$
+        XmlElement isParameterPresent = new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
+        isEqualElement.addAttribute(new Attribute("property", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
+        isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
+        isEqualElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
+        isParameterPresent.addElement(isEqualElement);
+        answer.addElement(isParameterPresent);
 
+        StringBuilder sb = new StringBuilder();
         if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
             sb.append('\'');
             sb.append(introspectedTable.getSelectByExampleQueryId());
             sb.append("' as QUERYID,"); //$NON-NLS-1$
+            answer.addElement(new TextElement(sb.toString()));
         }
-        answer.addElement(new TextElement(sb.toString()));
+        
         answer.addElement(getBaseColumnListElement());
         answer.addElement(new TextElement(",")); //$NON-NLS-1$
         answer.addElement(getBlobColumnListElement());

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java Tue Jan  5 16:36:05 2010
@@ -45,15 +45,23 @@
 
         ibatorContext.getCommentGenerator().addComment(answer);
 
-        StringBuilder sb = new StringBuilder();
-        sb.append("select "); //$NON-NLS-1$
+        answer.addElement(new TextElement("select")); //$NON-NLS-1$
+        XmlElement isParameterPresent = new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
+        isEqualElement.addAttribute(new Attribute("property", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
+        isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
+        isEqualElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
+        isParameterPresent.addElement(isEqualElement);
+        answer.addElement(isParameterPresent);
 
+        StringBuilder sb = new StringBuilder();
         if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
             sb.append('\'');
             sb.append(introspectedTable.getSelectByExampleQueryId());
             sb.append("' as QUERYID,"); //$NON-NLS-1$
+            answer.addElement(new TextElement(sb.toString()));
         }
-        answer.addElement(new TextElement(sb.toString()));
+        
         answer.addElement(getBaseColumnListElement());
 
         sb.setLength(0);

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/model/ExampleGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/model/ExampleGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/model/ExampleGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/model/ExampleGenerator.java Tue Jan  5 16:36:05 2010
@@ -95,6 +95,31 @@
         commentGenerator.addGeneralMethodComment(method, introspectedTable);
         topLevelClass.addMethod(method);
 
+        // add field, getter, setter for distinct
+        field = new Field();
+        field.setVisibility(JavaVisibility.PROTECTED);
+        field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
+        field.setName("distinct"); //$NON-NLS-1$
+        commentGenerator.addFieldComment(field, introspectedTable);
+        topLevelClass.addField(field);
+
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setName("setDistinct"); //$NON-NLS-1$
+        method.addParameter(new Parameter(FullyQualifiedJavaType
+                .getBooleanPrimitiveInstance(), "distinct")); //$NON-NLS-1$
+        method.addBodyLine("this.distinct = distinct;"); //$NON-NLS-1$
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
+        method.setName("isDistinct"); //$NON-NLS-1$
+        method.addBodyLine("return distinct;"); //$NON-NLS-1$
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+        
         // add field and methods for the list of ored criteria
         field = new Field();
         field.setVisibility(JavaVisibility.PROTECTED);
@@ -148,6 +173,8 @@
         method.setVisibility(JavaVisibility.PUBLIC);
         method.setName("clear"); //$NON-NLS-1$
         method.addBodyLine("oredCriteria.clear();"); //$NON-NLS-1$
+        method.addBodyLine("orderByClause = null;"); //$NON-NLS-1$
+        method.addBodyLine("distinct = false;"); //$NON-NLS-1$
         commentGenerator.addGeneralMethodComment(method, introspectedTable);
         topLevelClass.addMethod(method);
 

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java Tue Jan  5 16:36:05 2010
@@ -46,15 +46,20 @@
 
         ibatorContext.getCommentGenerator().addComment(answer);
 
+        answer.addElement(new TextElement("select")); //$NON-NLS-1$
+        XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
+        ifElement.addAttribute(new Attribute("test", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
+        ifElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
+        answer.addElement(ifElement);
+        
         StringBuilder sb = new StringBuilder();
-        sb.append("select "); //$NON-NLS-1$
-
         if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
             sb.append('\'');
             sb.append(introspectedTable.getSelectByExampleQueryId());
             sb.append("' as QUERYID,"); //$NON-NLS-1$
+            answer.addElement(new TextElement(sb.toString()));
         }
-        answer.addElement(new TextElement(sb.toString()));
+        
         answer.addElement(getBaseColumnListElement());
         answer.addElement(new TextElement(",")); //$NON-NLS-1$
         answer.addElement(getBlobColumnListElement());
@@ -65,7 +70,7 @@
         answer.addElement(new TextElement(sb.toString()));
         answer.addElement(getExampleIncludeElement());
 
-        XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
+        ifElement = new XmlElement("if"); //$NON-NLS-1$
         ifElement.addAttribute(new Attribute("test", "orderByClause != null")); //$NON-NLS-1$ //$NON-NLS-2$
         ifElement
                 .addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$

Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java Tue Jan  5 16:36:05 2010
@@ -46,15 +46,19 @@
 
         ibatorContext.getCommentGenerator().addComment(answer);
 
-        StringBuilder sb = new StringBuilder();
-        sb.append("select "); //$NON-NLS-1$
+        answer.addElement(new TextElement("select")); //$NON-NLS-1$
+        XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
+        ifElement.addAttribute(new Attribute("test", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
+        ifElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
+        answer.addElement(ifElement);
 
+        StringBuilder sb = new StringBuilder();
         if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
             sb.append('\'');
             sb.append(introspectedTable.getSelectByExampleQueryId());
             sb.append("' as QUERYID,"); //$NON-NLS-1$
+            answer.addElement(new TextElement(sb.toString()));
         }
-        answer.addElement(new TextElement(sb.toString()));
         answer.addElement(getBaseColumnListElement());
 
         sb.setLength(0);
@@ -63,7 +67,7 @@
         answer.addElement((new TextElement(sb.toString())));
         answer.addElement(getExampleIncludeElement());
 
-        XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
+        ifElement = new XmlElement("if"); //$NON-NLS-1$
         ifElement
                 .addAttribute(new Attribute("test", "orderByClause != null")); //$NON-NLS-1$ //$NON-NLS-2$
         ifElement

Modified: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/FlatJava2Test.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/FlatJava2Test.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/FlatJava2Test.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java2/src/test/java/ibatortest/java2/execute/flat/java2/FlatJava2Test.java Tue Jan  5 16:36:05 2010
@@ -113,6 +113,45 @@
         }
     }
 
+    public void testFieldsOnlySelectByExampleDistinct() {
+        FieldsonlyDAO dao = getFieldsonlyDAO();
+
+        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);
+            dao.insert(record);
+            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().andIntegerfieldEqualTo(new Integer(5));
+            example.setDistinct(true);
+
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            example.clear();
+            answer = dao.selectByExample(example);
+            assertEquals(5, answer.size());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+    
     public void testFieldsOnlySelectByExampleNoCriteria() {
         FieldsonlyDAO dao = getFieldsonlyDAO();
 
@@ -140,6 +179,9 @@
 
             List answer = dao.selectByExample(example);
             assertEquals(3, answer.size());
+
+            answer = dao.selectByExample(null);
+            assertEquals(3, answer.size());
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java2/FlatJava2Test.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java2/FlatJava2Test.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java2/FlatJava2Test.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java2/FlatJava2Test.java Tue Jan  5 16:36:05 2010
@@ -116,6 +116,46 @@
     }
 
     @SuppressWarnings("unchecked")
+    public void testFieldsOnlySelectByExampleDistinct() {
+        FieldsonlyDAO dao = getFieldsonlyDAO();
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(11.22);
+            record.setFloatfield(33.44);
+            record.setIntegerfield(5);
+            dao.insert(record);
+            dao.insert(record);
+            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().andIntegerfieldEqualTo(5);
+            example.setDistinct(true);
+
+            List answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            example.clear();
+            answer = dao.selectByExample(example);
+            assertEquals(5, answer.size());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
     public void testFieldsOnlySelectByExampleNoCriteria() {
         FieldsonlyDAO dao = getFieldsonlyDAO();
 
@@ -143,6 +183,9 @@
 
             List answer = dao.selectByExample(example);
             assertEquals(3, answer.size());
+
+            answer = dao.selectByExample(null);
+            assertEquals(3, answer.size());
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis2-java5/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java Tue Jan  5 16:36:05 2010
@@ -113,6 +113,45 @@
         }
     }
 
+    public void testFieldsOnlySelectByExampleDistinct() {
+        FieldsonlyDAO dao = getFieldsonlyDAO();
+
+        try {
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(11.22);
+            record.setFloatfield(33.44);
+            record.setIntegerfield(5);
+            dao.insert(record);
+            dao.insert(record);
+            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().andIntegerfieldEqualTo(5);
+            example.setDistinct(true);
+
+            List<Fieldsonly> answer = dao.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            example.clear();
+            answer = dao.selectByExample(example);
+            assertEquals(5, answer.size());
+        } catch (SQLException e) {
+            fail(e.getMessage());
+        }
+    }
+    
     public void testFieldsOnlySelectByExampleNoCriteria() {
         FieldsonlyDAO dao = getFieldsonlyDAO();
 
@@ -140,6 +179,9 @@
 
             List<Fieldsonly> answer = dao.selectByExample(example);
             assertEquals(3, answer.size());
+
+            answer = dao.selectByExample(null);
+            assertEquals(3, answer.size());
         } catch (SQLException e) {
             fail(e.getMessage());
         }

Modified: ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java?rev=896120&r1=896119&r2=896120&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java Tue Jan  5 16:36:05 2010
@@ -123,6 +123,47 @@
     }
 
     @Test
+    public void testFieldsOnlySelectByExampleDistinct() {
+        SqlSession sqlSession = sqlSessionFactory.openSession();
+
+        try {
+            FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
+            Fieldsonly record = new Fieldsonly();
+            record.setDoublefield(11.22);
+            record.setFloatfield(33.44);
+            record.setIntegerfield(5);
+            mapper.insert(record);
+            mapper.insert(record);
+            mapper.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(44.55);
+            record.setFloatfield(66.77);
+            record.setIntegerfield(8);
+            mapper.insert(record);
+
+            record = new Fieldsonly();
+            record.setDoublefield(88.99);
+            record.setFloatfield(100.111);
+            record.setIntegerfield(9);
+            mapper.insert(record);
+
+            FieldsonlyExample example = new FieldsonlyExample();
+            example.createCriteria().andIntegerfieldEqualTo(5);
+            example.setDistinct(true);
+
+            List<Fieldsonly> answer = mapper.selectByExample(example);
+            assertEquals(1, answer.size());
+
+            example.clear();
+            answer = mapper.selectByExample(example);
+            assertEquals(5, answer.size());
+        } finally {
+            sqlSession.close();
+        }
+    }
+
+    @Test
     public void testFieldsOnlySelectByExampleNoCriteria() {
         SqlSession sqlSession = sqlSessionFactory.openSession();
 
@@ -151,6 +192,9 @@
 
             List<Fieldsonly> answer = mapper.selectByExample(example);
             assertEquals(3, answer.size());
+
+            answer = mapper.selectByExample(null);
+            assertEquals(3, answer.size());
         } finally {
             sqlSession.close();
         }