iBatis resultMap出错 The error happened while setting a property on the result object 解决办法
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>
總結
以上是生活随笔為你收集整理的iBatis resultMap出错 The error happened while setting a property on the result object 解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Maven 单元测试
- 下一篇: 用MySql的查询分析语法explain