`

iBatis resultMap出错

    博客分类:
  • WARN
阅读更多
在操作休假功能时,错误:
ERROR [http-8080-3] - 执行:class com.ving.xzfw.persistence.impl.CaseDaoImpl.getList()方法出错!
ERROR [http-8080-3] - SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; 
--- The error occurred in com/ving/xzfw/persistence/sqlmap/Case.xml. 
--- The error occurred while applying a result map. 
--- Check the Case.getList-AutoResultMap. 
--- 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/ving/xzfw/persistence/sqlmap/Case.xml.
--- The error occurred while applying a result map
--- Check the Case.getList-AutoResultMap. 
--- The error happened while setting a property on the result object. 
--- Cause: net.sf.cglib.beans.BulkBeanException
ERROR [http-8080-3] - case.getList()失败
ERROR [http-8080-3] - 错误发生在:HolidayDaoSerivice.insertHoliday(Holiday holi)方法中!
ERROR [http-8080-3] - 调用updateOrInsert方法失败

分析:
这个错误指出resultMap里有问题。说错误发生在设置某一个属性的时候,出现null!
但没有指明那个属性(也就是对应的字段)。
看下配置文件
    <resultMap id="HolidayResult" class="HolidayObject">
        <result property="holiId" column="holiid"/>
        <result property="holiType" column="holiType"/>
        <result property="holiStartDate" column="holistartDate"/>
        <result property="holiEndDate" column="holiendDate"/>
        <result property="holiName" column="holiname"/>       
        <result property="holiRemark" column="holiremark" nullValue=""/>
    </resultMap>
      </sql>
验证
很简单在sql server里写一条sql 语句:select * from  T_holiday
执行后发现remark字段有的为空,O(∩_∩)O~,找到问题根结啦。
解决
   <result property="holiRemark" column="holiremark" nullValue=""/>
完结!呵呵,只要报错,就能找到问题原因
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics