在使用Hibernate进行批量插入的时报错:
insert into JIAOFEI_JILU (version, KH_LX, KH_ID, YQDZ_ID, JFJL_YQDZ_MS, JFJL_HZ_MC, JFJL_LXDH, JFJL_ZT, JFJL_BEIZHU, JFJL_YJE, JFJL_YHJE, JFJL_ZNJ, JFJL_ZNJ_JM, ZH_ID, JFJL_SJJKFS_ID, JFJL_JYLSH, JFJL_SJJFRQ, JFJL_SJJFE, JFJL_SJZNJ, JFJL_JFQYUE, JFJL_YUJIAO, JFJL_JIECUN, JFJL_YYT, JFJL_SFYG, JFJL_YHH, JFJL_YH_WANGDIAN, JFJL_YH_GUIYUAN, JFJL_YHZH_LX, JFJL_YHZH, ORG_ID, Jfjl_jiezhuan_bz, JFJL_YQZH, JFJL_jflx_id, JFJL_JE, JFJL_PJH, Jfjl_id_old, JFJL_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
错误信息:
=2011-12-08 18:23:11 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1401, SQLState: 23000
=2011-12-08 18:23:11 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01401: 插入的值对于列过大
=2011-12-08 18:23:11 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1401, SQLState: 23000
=2011-12-08 18:23:11 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01401: 插入的值对于列过大
对与以上错误无法分析到底是那个值过大,所以如果能显示出每个参数的值就应该解决了;
在网上找了两种解决方法最简单的就是在log4j.properties文件里面加一几个配置项:
log4j.appender.STDOUT.Threshold=trace
log4j.category.org.hibernate.SQL=trace
log4j.category.org.hibernate.type=trace
重新启动输出日志:
=TRACE [org.hibernate.type.StringType] binding 'huajun' to parameter: 1
=TRACE [org.hibernate.type.StringType] binding null to parameter: 2
=TRACE [org.hibernate.type.StringType] binding '0083' to parameter: 3
=TRACE [org.hibernate.type.StringType] binding '交费帐户存入' to parameter: 4
=TRACE [org.hibernate.type.BigDecimalType] binding '0.00' to parameter: 5
=TRACE [org.hibernate.type.BigDecimalType] binding '0.05' to parameter: 6
=TRACE [org.hibernate.type.StringType] binding '胡中伟 ' to parameter: 7
=TRACE [org.hibernate.type.StringType] binding '7' to parameter: 8
=TRACE [org.hibernate.type.StringType] binding '1' to parameter: 9
=TRACE [org.hibernate.type.StringType] binding null to parameter: 10
=TRACE [org.hibernate.type.TimestampType] binding '2011-12-08 19:17:35' to parameter: 11
=TRACE [org.hibernate.type.StringType] binding '' to parameter: 12
=TRACE [org.hibernate.type.StringType] binding null to parameter: 13
=TRACE [org.hibernate.type.StringType] binding null to parameter: 14
=TRACE [org.hibernate.type.StringType] binding null to parameter: 15
=TRACE [org.hibernate.type.StringType] binding null to parameter: 16
=TRACE [org.hibernate.type.StringType] binding '111208175146' to parameter: 17
=TRACE [org.hibernate.type.StringType] binding null to parameter: 18
=TRACE [org.hibernate.type.TimestampType] binding null to parameter: 19
=TRACE [org.hibernate.type.StringType] binding '6000056690' to parameter: 20
发现第个参数中有很多空格;OK 解决了