Skip to content

Commit 17bfc16

Browse files
committed
Related to #62. Fix and test for mapped properties.
1 parent 608209c commit 17bfc16

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap,
369369
if (value != null || !metaObject.getSetterType(property).isPrimitive()) {
370370
metaObject.setValue(property, value);
371371
}
372-
foundValues = (value != null) || foundValues;
372+
foundValues = true;
373373
}
374374
}
375375
}

src/test/java/org/apache/ibatis/submitted/call_setters_on_nulls/CallSettersOnNullsTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,16 @@ public void shouldCallNullOnMapForSingleColumn() {
101101
}
102102
}
103103

104+
@Test
105+
public void shouldCallNullOnMapForSingleColumnWithResultMap() {
106+
SqlSession sqlSession = sqlSessionFactory.openSession();
107+
try {
108+
Mapper mapper = sqlSession.getMapper(Mapper.class);
109+
List<Map<String, Object>> oneColumns = mapper.getNameOnlyMapped();
110+
Assert.assertNotNull(oneColumns.get(1));
111+
} finally {
112+
sqlSession.close();
113+
}
114+
}
115+
104116
}

src/test/java/org/apache/ibatis/submitted/call_setters_on_nulls/Mapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public interface Mapper {
2424
User getUserUnmapped(Integer id);
2525
Map getUserInMap(Integer id);
2626
List<Map<String,Object>> getNameOnly();
27+
List<Map<String,Object>> getNameOnlyMapped();
2728

2829
}

src/test/java/org/apache/ibatis/submitted/call_setters_on_nulls/Mapper.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@
4141
select name from users2
4242
</select>
4343

44+
<select id="getNameOnlyMapped" resultMap="mapResult">
45+
select name from users2
46+
</select>
47+
48+
<resultMap type="map" id="mapResult">
49+
<result column="name" property="name" />
50+
</resultMap>
51+
4452
</mapper>

0 commit comments

Comments
 (0)