ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbe...@apache.org
Subject svn commit: r293211 - /ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java
Date Mon, 03 Oct 2005 02:29:31 GMT
Author: cbegin
Date: Sun Oct  2 19:29:28 2005
New Revision: 293211

URL: http://svn.apache.org/viewcvs?rev=293211&view=rev
Log:
Fixed IBATIS-172 implicit mapping fails on nested column aliases

Modified:
    ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java

Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java?rev=293211&r1=293210&r2=293211&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java
(original)
+++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/AutoResultMap.java
Sun Oct  2 19:29:28 2005
@@ -16,6 +16,8 @@
 package com.ibatis.sqlmap.engine.mapping.result;
 
 import com.ibatis.common.beans.ClassInfo;
+import com.ibatis.common.beans.Probe;
+import com.ibatis.common.beans.ProbeFactory;
 import com.ibatis.common.exception.NestedRuntimeException;
 import com.ibatis.sqlmap.client.SqlMapException;
 import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
@@ -83,17 +85,26 @@
         String columnName = rsmd.getColumnLabel(i + 1);
         String upperColumnName = columnName.toUpperCase();
         String matchedProp = (String) propertyMap.get(upperColumnName);
-        if (matchedProp != null) {
+        Class type = null;
+        if (matchedProp == null) {
+          Probe p = ProbeFactory.getProbe(this.getResultClass());
+          try {
+            type = p.getPropertyTypeForSetter(this.getResultClass(), columnName);
+          } catch (Exception e) {
+            //TODO - add logging to this class?
+          }
+        } else {
+          type = classInfo.getSetterType(matchedProp);
+        }
+        if (type != null || matchedProp != null) {
           BasicResultMapping resultMapping = new BasicResultMapping();
-          resultMapping.setPropertyName(matchedProp);
+          resultMapping.setPropertyName((matchedProp != null ? matchedProp : columnName));
           resultMapping.setColumnName(columnName);
           resultMapping.setColumnIndex(i + 1);
-          Class type = classInfo.getSetterType(matchedProp);
-          resultMapping.setTypeHandler(getDelegate().getTypeHandlerFactory().getTypeHandler(type));
+          resultMapping.setTypeHandler(getDelegate().getTypeHandlerFactory().getTypeHandler(type));
//map SQL to JDBC type
           resultMappingList.add(resultMapping);
         }
       }
-
       setResultMappingList(resultMappingList);
 
     } catch (SQLException e) {



Mime
View raw message