iBatis resultMap出错 The error happened while setting a property on the result object 解决办法
http://blog.csdn.net/itshu/article/details/3402253
錯(cuò)誤:
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. ?
這個(gè)錯(cuò)誤是resultMap里有問題。說錯(cuò)誤發(fā)生在設(shè)置某一個(gè)屬性的時(shí)候,但是沒有具體說明是一個(gè)怎么樣的錯(cuò)誤<NULL錯(cuò)誤>。可能就
是把某一列中不為null的值賦了null值(double等),這樣的話在resultMap里面作修改就行了。
肯定是iBatis試圖把從數(shù)據(jù)庫(kù)讀出來的NULL 值寫入對(duì)象屬性的時(shí)候出現(xiàn)異常。String類型的賦值應(yīng)該沒問題,我的數(shù)據(jù)庫(kù)中還
有double類型的,那就是這個(gè)問題了,采取的補(bǔ)救措施就是:
?<result column="RATE" jdbcType="DECIMAL" property="rate" nullValue="0"/>
對(duì)從數(shù)據(jù)庫(kù)讀出來的NULL值采用一個(gè)相應(yīng)可轉(zhuǎn)換為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"/>
? <!--這一行加一個(gè)nullValue="0"就OK了-->
?
</resultMap>
總結(jié)
以上是生活随笔為你收集整理的iBatis resultMap出错 The error happened while setting a property on the result object 解决办法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Maven 单元测试
- 下一篇: 用MySql的查询分析语法explain