Cause: net.sf.cglib.beans.BulkBeanException异常

今天升级现网时遇到一个问题!但在本地开发的时候却没有出现过这样的问题,现网的系统是linux。
异常信息如下:

com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlmaps/sql-t.xml.
--- The error occurred while applying a result map.
--- Check the Task.result-task-obj.
--- The error happened while setting a property on the result object.
--- Cause: net.sf.cglib.beans.BulkBeanException
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:204)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:94)

最后通过baidu一下知道了异常Cause: net.sf.cglib.beans.BulkBeanException引起的原因是数据库表中有一个可以为空的列(列的类型是number),当查询的时候由于该列没有值ibtis会用null去初始化该列,但把null类型赋值给number类型的值时,出现如上异常信息。解决方法是找到ibatis配置文件sql-t.xml中的
<resultMap id="result-task-obj" class="Task_Obj">
<result property="duplicated" column="DUPLICATED"/>
</resultMap>



<result property="duplicated" column="DUPLICATED"/>
修改成
<result property="duplicated" column="DUPLICATED" nullValue="0"/>
即当DUPLICATED列对应的值为null时,会用0值初始化duplicated属性(duplicated对应其类中的数据类型是int)。修改后系统运行正常。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值