Skip to content

Commit

Permalink
fixes #1590 Ensure composite to be empty when unnecessary column
Browse files Browse the repository at this point in the history
…is specified

Although more active solution (e.g. output a warning) might be better, there could be a use case that I am not aware of.
  • Loading branch information
harawata committed Jul 5, 2019
1 parent a094323 commit 3becd0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -16,6 +16,7 @@
package org.apache.ibatis.builder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -369,7 +370,12 @@ public ResultMapping buildResultMapping(
boolean lazy) {
Class<?> javaTypeClass = resolveResultJavaType(resultType, property, javaType);
TypeHandler<?> typeHandlerInstance = resolveTypeHandler(javaTypeClass, typeHandler);
List<ResultMapping> composites = parseCompositeColumnName(column);
List<ResultMapping> composites;
if ((nestedSelect == null || nestedSelect.isEmpty()) && (foreignColumn == null || foreignColumn.isEmpty())) {
composites = Collections.emptyList();
} else {
composites = parseCompositeColumnName(column);
}
return new ResultMapping.Builder(configuration, property, column, javaTypeClass)
.jdbcType(jdbcType)
.nestedQueryId(applyCurrentNamespace(nestedSelect, true))
Expand Down
Expand Up @@ -26,7 +26,8 @@
<id column="carid" property="id"/>
<result column="cartype" property="type"/>
<association property="engine" resultMap="engineResult"/>
<association property="brakes" resultMap="brakesResult"/>
<!-- the bogus 'column' below is to assert gh-1590 -->
<association property="brakes" resultMap="brakesResult" column="{carid=carid}" />
</resultMap>
<resultMap type="org.apache.ibatis.submitted.associationtest.Engine" id="engineResult">
<result column="enginetype" property="type"/>
Expand Down

0 comments on commit 3becd0a

Please sign in to comment.