ibatis动态列缺陷,remapResults

--- The error occurred in com/kingdee/youshang/basedata/mapper/ProductOnSale.xml.
--- The error occurred while applying a result map.
--- Check the ProductOnSale.ProductOnSaleResult.
--- Check the result mapping for the 'id' property.
--- Cause: java.sql.SQLException: 列名无效]; SQL was [] for task [SqlMapClient operation]


出现这种问题,可能是sql得select使用得动态列,不用条件会返回不同得列,此时ibatis会缓存列,导致如果换成少字段得话,多字段得查询会报上面得错误

需要使用属性

remapResults="true"


  1. <select id="" resultClass="java.util.HashMap"

  2. parameterClass="java.util.HashMap" remapResults="true">

每次执行sql都重新映射列名

{context}