ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbe...@apache.org
Subject svn commit: r833290 - in /ibatis/java/ibatis-3/trunk/ibatis-3-core/src: main/java/org/apache/ibatis/executor/resultset/ test/java/org/apache/ibatis/submitted/multiple_discriminator/
Date Fri, 06 Nov 2009 03:24:58 GMT
Author: cbegin
Date: Fri Nov  6 03:24:58 2009
New Revision: 833290

URL: http://svn.apache.org/viewvc?rev=833290&view=rev
Log:
IBATIS-679 re-fix

Modified:
    ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java
    ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/CreateDB.sql
    ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/MultipleDiscriminatorTest.java
    ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/Person.xml
    ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/PersonMapper.java

Modified: ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java?rev=833290&r1=833289&r2=833290&view=diff
==============================================================================
--- ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java
(original)
+++ ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java
Fri Nov  6 03:24:58 2009
@@ -21,6 +21,7 @@
 import java.sql.*;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -384,6 +385,7 @@
   //
 
   public ResultMap resolveDiscriminatedResultMap(ResultSet rs, ResultMap resultMap) throws
SQLException {
+    Set<String> pastDiscriminators = new HashSet<String>();
     Discriminator discriminator = resultMap.getDiscriminator();
     while (discriminator != null) {
       final Object value = getDiscriminatorValue(rs, discriminator);
@@ -392,7 +394,7 @@
         resultMap = configuration.getResultMap(discriminatedMapId);
         Discriminator lastDiscriminator = discriminator;
         discriminator = resultMap.getDiscriminator();
-        if (discriminator == lastDiscriminator) {
+        if (discriminator == lastDiscriminator || !pastDiscriminators.add(discriminatedMapId))
{
           break;
         }
       } else {

Modified: ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/CreateDB.sql
URL: http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/CreateDB.sql?rev=833290&r1=833289&r2=833290&view=diff
==============================================================================
--- ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/CreateDB.sql
(original)
+++ ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/CreateDB.sql
Fri Nov  6 03:24:58 2009
@@ -10,3 +10,6 @@
 
 INSERT INTO person (id, firstName, lastName, jobTitle, department, personType, employeeType)
 VALUES (1, 'John', 'Smith', 'IT director', 'IT', 'EmployeeType', 'DirectorType');
+
+INSERT INTO person (id, firstName, lastName, jobTitle, department, personType, employeeType)
+VALUES (3, 'John', 'Smith', 'IT director', 'IT', 'EmployeeType', 'PersonType');

Modified: ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/MultipleDiscriminatorTest.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/MultipleDiscriminatorTest.java?rev=833290&r1=833289&r2=833290&view=diff
==============================================================================
--- ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/MultipleDiscriminatorTest.java
(original)
+++ ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/MultipleDiscriminatorTest.java
Fri Nov  6 03:24:58 2009
@@ -62,4 +62,10 @@
         Assert.assertNotNull("Person must not be null", person);
         Assert.assertEquals("Person must be a director", (Object)Director.class, (Object)person.getClass());
     }
+    @Test(timeout=20000)
+    public void testMultipleDiscriminatorLoop() {
+        SqlSession sqlSession = sqlSessionFactory.openSession();
+        PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
+        personMapper.getLoop();
+    }
 }

Modified: ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/Person.xml
URL: http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/Person.xml?rev=833290&r1=833289&r2=833290&view=diff
==============================================================================
--- ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/Person.xml
(original)
+++ ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/Person.xml
Fri Nov  6 03:24:58 2009
@@ -34,6 +34,21 @@
     <resultMap id="directorMap" type="Director" extends="employeeMap">
         <result property="department" column="department"/>
     </resultMap>
+    <resultMap id="personMapLoop" type="Person">
+        <id property="id" column="id"/>
+        <result property="firstName" column="firstName"/>
+        <result property="lastName" column="lastName"/>
+        <discriminator column="personType" javaType="String">
+            <case value="EmployeeType" resultMap="employeeMapLoop"/>
+        </discriminator>
+    </resultMap>
+    <resultMap id="employeeMapLoop" type="Employee">
+        <result property="jobTitle" column="jobTitle"/>
+        <discriminator column="employeeType" javaType="String">
+            <case value="PersonType" resultMap="personMapLoop"/>
+        </discriminator>
+    </resultMap>
+    
     
     <select id="get" resultMap="personMap" parameterType="long">
         SELECT id, firstName, lastName, jobTitle, department, personType, employeeType
@@ -45,5 +60,10 @@
         FROM Person
         WHERE id = #{id}
     </select>
+    <select id="getLoop" resultMap="personMapLoop">
+        SELECT id, firstName, lastName, jobTitle, department, personType, employeeType
+        FROM Person
+        WHERE id = 3
+    </select>
     
 </mapper>

Modified: ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/PersonMapper.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/PersonMapper.java?rev=833290&r1=833289&r2=833290&view=diff
==============================================================================
--- ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/PersonMapper.java
(original)
+++ ibatis/java/ibatis-3/trunk/ibatis-3-core/src/test/java/org/apache/ibatis/submitted/multiple_discriminator/PersonMapper.java
Fri Nov  6 03:24:58 2009
@@ -4,4 +4,5 @@
     
     public Person get(Long id);
     public Person get2(Long id);
+    public Person getLoop();
 }



Mime
View raw message