Closed
Description
MyBatis version
3.3.0+
(example and lines below are based on the 3.5.1)
Database vendor and version
PostgreSQL 9.6 or H2 1.4
Steps to reproduce
- Have an association in a mapper based on a composite key
- Use any request using the resultMap
Mapper example:
<mapper namespace="my.package.VariableMapper">
<resultMap id="BaseResultMap" type="VariableImpl">
<id column="va_process_id" property="processId" jdbcType="INTEGER" />
<id column="va_variable_id" property="variableId" jdbcType="VARCHAR" />
[...]
</resultMap>
<resultMap id="CompleteResultMap" type="VariableImpl" extends="BaseResultMap">
<association property="linkedVariable" column="{processId=lv_va_process_id,variableId=lv_va_variable_id}"
javaType="VariableImpl" resultMap="my.package.VariableMapper.BaseResultMap" columnPrefix="lv_"/>
[...]
</resultMap>
[...]
</mapper>
Expected result
The request done, as in 3.2.8-
Actual result
NPE on DefaultResultSetHandler L472 with typeHandler as null
Cause: java.lang.NullPointerException
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy44.selectById(Unknown Source)
[...]
Caused by: java.lang.NullPointerException
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:472)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:441)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:905)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForNestedResultMap(DefaultResultSetHandler.java:870)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:326)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
... 36 more
The problem seems to comes from this commit : 9d29135
where those three lines were deleted :
if (composites.size() > 0) { column = null; }
In case of composite column, the value of this property is then keept instead of removed and the treatment is done as it was a simple column and not a composite one so the typeHandler is null as there is no real data behind this propertyMapping.
Best regards,
Nicolas