在使用mybatis中使用 foreach 時,出現了一個詭異的bug
java文件中是
List<ImportTaskInfoEntity> selectByCalcBatchIds(@Param("ids") List<String> ids);
xml中是
<foreach collection="ids" index="index" item="item"
separator="or" open="(" close=")">
calc_batch_id = #{item}
</foreach>
按理,String直接取是ok,但是卻取不到。查看異常為
Type handler was null on parameter mapping for property '__frch_item_0'. It was either not specified and/or could not be found for the javaType (com.xxx.sale.cmis.entity.AuditTaskEntity) : jdbcType (null) combination.
故猜測,mybatis將集合的元素轉化成了 AuditTaskEntity ,故取值改成 calc_batch_id = #{item.calcBatchId} ,居然就通過了。
實在無解...................