Ibatis 報:org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized S
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>