现在的位置: 首页 > 综合 > 正文

iBatis resultMap出错 The error happened while setting a property on the result object 解决办法

2014年11月25日 ⁄ 综合 ⁄ 共 1257字 ⁄ 字号 评论关闭

http://blog.csdn.net/itshu/article/details/3402253

错误:
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; 

SQL state [null]; error code [0];  
--- The error occurred in com/sinosoft/para/conf/A_T_4_SqlMap.xml.  
--- The error occurred while applying a result map.  
--- Check the A_T_4.A_T_4Result.  
--- The error happened while setting a property on the result object.  
--- Cause: net.sf.cglib.beans.BulkBeanException; nested exception is 

com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/sinosoft/para/conf/A_T_4_SqlMap.xml.  
--- The error occurred while applying a result map.  
--- Check the A_T_4.A_T_4Result.  
--- The error happened while setting a property on the result object.  

这个错误是resultMap里有问题。说错误发生在设置某一个属性的时候,但是没有具体说明是一个怎么样的错误<NULL错误>。可能就

是把某一列中不为null的值赋了null值(double等),这样的话在resultMap里面作修改就行了。
  肯定是iBatis试图把从数据库读出来的NULL 值写入对象属性的时候出现异常。String类型的赋值应该没问题,我的数据库中还

有double类型的,那就是这个问题了,采取的补救措施就是:
 <result column="RATE" jdbcType="DECIMAL" property="rate" nullValue="0"/>
对从数据库读出来的NULL值采用一个相应可转换为DECIMAL类型或者double类型的值来替换

附:
 
sqlMap:
<resultMap class="com.sinosoft.para.bean.A_t_4_6" id="A_T_4_6Result">
  <result property="id" column="user_id"/>
  <result column="RATE" jdbcType="DECIMAL" property="rate" nullValue="0"/>
  <!--这一行加一个nullValue="0"就OK了-->
 
</resultMap>

抱歉!评论已关闭.