快捷搜索: 王者荣耀 脱发

使用ibatis抛出NestedSQLException异常

使用ibatis抛出NestedSQLException异常

昨天还很正常的程序什么都没改动,今天运行就抛出如下异常:

com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in com/contract/ibatis/mapping/PayInfo.xml. --- The error occurred while applying a result map. --- Check the getPayInfoByContractCodeOrPayType-AutoResultMap. --- The error happened while setting a property on the result object. --- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of com.contract.struts.form.PayInfoForm@15b7644. Cause: java.lang.IllegalArgumentException Caused by: java.lang.IllegalArgumentException

反复检查各个文件,始终找不出问题所在。baidu,google了半天,碰到过这个异常的人不多,还多是些外国人,只有提问的没有回答的,找了一下午眼睛备受摧残。

最后在我无数次的试验过程中,终于知道为什么会抛这个异常了。xml,DAO,form,action都没问题,问题的根源在于数据库里的一条记录,在定义表的时候有几个字段定义了默认值,而我一上午都在试存储过程,试的时候插进去了一条记录,本该有默认值的那几个字段为空,所以The error happened while setting a property on the result object. 把那条记录的那几个字段改成默认值,一切OK。

昨天还很正常的程序什么都没改动,今天运行就抛出如下异常: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in com/contract/ibatis/mapping/PayInfo.xml. --- The error occurred while applying a result map. --- Check the getPayInfoByContractCodeOrPayType-AutoResultMap. --- The error happened while setting a property on the result object. --- Cause: com.ibatis.common.exception.NestedRuntimeException: Error setting properties of com.contract.struts.form.PayInfoForm@15b7644. Cause: java.lang.IllegalArgumentException Caused by: java.lang.IllegalArgumentException 反复检查各个文件,始终找不出问题所在。baidu,google了半天,碰到过这个异常的人不多,还多是些外国人,只有提问的没有回答的,找了一下午眼睛备受摧残。 最后在我无数次的试验过程中,终于知道为什么会抛这个异常了。xml,DAO,form,action都没问题,问题的根源在于数据库里的一条记录,在定义表的时候有几个字段定义了默认值,而我一上午都在试存储过程,试的时候插进去了一条记录,本该有默认值的那几个字段为空,所以The error happened while setting a property on the result object. 把那条记录的那几个字段改成默认值,一切OK。
经验分享 程序员 微信小程序 职场和发展