Skip to content

Commit 54b4fa5

Browse files
committed
Fix for issue #1848
1 parent 907929a commit 54b4fa5

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,7 @@ private List<ResultMapping> getResultMappingsForRowKey(ResultMap resultMap) {
10481048

10491049
private void createRowKeyForMappedProperties(ResultMap resultMap, ResultSetWrapper rsw, CacheKey cacheKey, List<ResultMapping> resultMappings, String columnPrefix) throws SQLException {
10501050
for (ResultMapping resultMapping : resultMappings) {
1051-
if (resultMapping.getNestedResultMapId() != null && resultMapping.getResultSet() == null) {
1052-
// Issue #392
1053-
final ResultMap nestedResultMap = configuration.getResultMap(resultMapping.getNestedResultMapId());
1054-
createRowKeyForMappedProperties(nestedResultMap, rsw, cacheKey, nestedResultMap.getConstructorResultMappings(),
1055-
prependPrefix(resultMapping.getColumnPrefix(), columnPrefix));
1056-
} else if (resultMapping.getNestedQueryId() == null) {
1051+
if (resultMapping.isSimple()) {
10571052
final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
10581053
final TypeHandler<?> th = resultMapping.getTypeHandler();
10591054
List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);

src/main/java/org/apache/ibatis/mapping/ResultMapping.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ public boolean isLazy() {
250250
public void setLazy(boolean lazy) {
251251
this.lazy = lazy;
252252
}
253+
254+
public boolean isSimple() {
255+
return this.nestedResultMapId == null && this.nestedQueryId == null && this.resultSet == null;
256+
}
253257

254258
@Override
255259
public boolean equals(Object o) {

src/test/java/org/apache/ibatis/submitted/parent_childs/ParentChildTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.ibatis.session.SqlSession;
2424
import org.apache.ibatis.session.SqlSessionFactory;
2525
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
26-
import org.junit.Ignore;
2726
import org.junit.jupiter.api.Assertions;
2827
import org.junit.jupiter.api.BeforeAll;
2928
import org.junit.jupiter.api.Test;
@@ -62,7 +61,6 @@ void shouldGet2Parents() {
6261

6362
// issue #1848
6463
@Test
65-
@Ignore
6664
void shouldGet2ParentsWithConstructor() {
6765
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
6866
Mapper mapper = sqlSession.getMapper(Mapper.class);

0 commit comments

Comments
 (0)