iBatis resultMap出錯 The error happened while setting a property on the result object 解決辦法 .

錯誤:
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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章