mybatis插入数据库时的问题记录

时间:2021-04-16 21:43:30

mybatis接口调用如下

rowPropSubInfoMapper.insertRowPropSubInfo(iRowPropSubInfoModel);


使用的mapper配置如下

<insert id="insertRowPropSubInfo"        parameterType="com.sinosig.evaluation.fcff.model.dto.IRowPropSubInfoModel">        insert into        t_eva_fcff_row_property        (FCFFID,        ROWCODE,        ROWNAME,        ROWDESCRIPTION,        ISSHOW,        CURRENTPREMETHOD,        CURRENTPREVALUE,        CURRENTSCALEBASE,        WARNINGDESCRIPTION)        values        (#{fcffid},        #{code},        #{name},        #{description},        #{isshow},        #{currentPremethodCode},        #{currentPreValue},        #{currentScaleBase},        #{warningDescription})    </insert>


抛出的异常信息如下:

[DEBUG]2013-12-17 17:26:54,166 java.sql.Connection#debug()@47: ==>  Preparing: insert into t_eva_fcff_row_property (FCFFID, ROWCODE, ROWNAME, ROWDESCRIPTION, ISSHOW, CURRENTPREMETHOD, CURRENTPREVALUE, CURRENTSCALEBASE, WARNINGDESCRIPTION) values (?, ?, ?, ?, ?, ?, ?, ?, ?)[DEBUG]2013-12-17 17:26:54,166 org.mybatis.spring.SqlSessionUtils#debug()@47: Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2a851f][DEBUG]2013-12-17 17:26:54,166 org.springframework.jdbc.datasource.DataSourceUtils#doReleaseConnection()@327: Returning JDBC Connection to DataSourceorg.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.ArrayIndexOutOfBoundsException: 9    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)    at $Proxy5.insert(Unknown Source)    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236)    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79)    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)    at $Proxy32.insertRowPropSubInfo(Unknown Source)    at com.sinosig.evaluation.fcff.service.manage.impl.RowPropSubInfoTempSaveImpl.visitRowPropSubInfo(RowPropSubInfoTempSaveImpl.java:111)    at com.sinosig.evaluation.fcff.model.impl.FcffModelImpl.acceptVisitor(FcffModelImpl.java:1203)    at com.sinosig.evaluation.fcff.service.manage.impl.RowPropSubInfoTempSaveImpl.updateSubInfo(RowPropSubInfoTempSaveImpl.java:77)    at com.sinosig.evaluation.fcff.service.manage.AbstractSaveSubInfoService.call(AbstractSaveSubInfoService.java:95)    at test.com.sinosig.evaluation.fcff.service.RowSubInfoSaveImplTest.testUpdateSubInfo(RowSubInfoSaveImplTest.java:43)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.ArrayIndexOutOfBoundsException: 9    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:91)    at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54)    at org.apache.ibatis.executor.ReuseExecutor.prepareStatement(ReuseExecutor.java:73)    at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:46)    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)    ... 33 moreCaused by: java.lang.ArrayIndexOutOfBoundsException: 9    at oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:950)    at oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:623)    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:1212)    at oracle.jdbc.driver.T4CPreparedStatement.<init>(T4CPreparedStatement.java:28)    at oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:68)    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3140)    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3042)    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:5890)    at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:508)    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:400)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:53)    at $Proxy33.prepareStatement(Unknown Source)    at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:65)    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82)    ... 45 more


尤其奇怪的是,如果在insert语句中,将插入的列减少到7列或以下,则能够正常执行;8列或以上就会抛出这个异常,并且java.lang.ArrayIndexOutOfBoundsException: 9最后的数字就是列数。


折磨了我整整三天了。如果算上以前的问题,至少折磨了我一个礼拜了。头大。

本文出自 “编程的摩羯男” 博客,请务必保留此出处http://winters1224.blog.51cto.com/3021203/1341638