Ibatis列名无效

最近在用ibatis连接Oracle,出现了几种列名无效的情况:

— 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语句映射文件:

1.查询语句返回的结果字段集不是所对应resultMap里面映射字段集的父集或相等,例如:

resultMap 映射为:

<resultMap class=”ProductOnSale” id=”ProductOnSaleResult”>
<result column=”FID” javaType=”long” jdbcType=”BIGINT” property=”id”/>
<result column=”FFUNDNAME” javaType=”string” jdbcType=”VARCHAR” property=”fundname”/>
</resultMap>

 

而SQL返回只有FFUNDNAME(没有FID):

<select id=”findProducts” resultMap=”ProductOnSaleResult”>/*dialect*/
SELECT FFUNDNAME FROM T_BS_PRODUCT_ON_SALE POS
</select>

2.resultMap配置里面的字段名前面加了表名:

<resultMap id=”ProductOnSaleResult”>
<result column=”POS.FID” javaType=”long” jdbcType=”BIGINT” property=”id”/>
<result column=”POS.FFUNDNAME” javaType=”string” jdbcType=”VARCHAR” property=”fundname”/>
</resultMap>

 

仅有1条评论 发表评论

  1. 梦瑶 /

    支持一下!!呵呵

发表评论