记录:
做项目的时候发现,在做insert操作时返回值一直为-2147482646。测试了一下发现错误时再mapper位置,可是再仔细看的话(好吧,也没跟着调试一点一点的看)未找到原因。然后上网搜到了该错误的根源。
解决方法:
在spring的配置文件中,只要把constructor-arg中的executorType改为SIMPLE(以前的值是BATCH就会引发这个问题)或者直接注释掉就可以了。
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"></constructor-arg>
<!-- 执行类型 -->
<constructor-arg name="executorType" value="SIMPLE"></constructor-arg>
</bean>
如果要想看具体原因,可以看一下这篇博客:https://www.cnblogs.com/wyq178/p/8652443.html