在用mybatis作刪除業務時,去返回值,得到-2147482646
原因是 開啟了BATCH,在applicationContext.xml中配置的mybatis
<!--為這次兩個不一致的提交,而打開,測試如何 --> <bean class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactoryBean"></constructor-arg> <!-- 打開此處,delete業務返回值為-2147482646,有異常。關閉批處理后,在作刪除業務時,返回值為0,或1,正常 . 此處有三個選項 SIMPLE, REUSE, BATCH,默認SIMPLE, REUSE 是復用預處理語句,BATCH是批量更新 <constructor-arg name="executorType" value="BATCH"></constructor-arg> --> <constructor-arg name="executorType" value="REUSE"></constructor-arg> </bean>
將其改為REUSE ,就可以了。返回值有了,但批處理呢?
另外:
在mapper文件中寫出這樣:
<delete id="deleteZhouyiContent" parameterType="java.lang.Long"> <![CDATA[ delete from tbl_content where id = #{id,jdbcType=INTEGER} ]]> </delete>
前后加上CDATA,據說也管用,這個我沒測試,這兩個我都用上了,現在狀態ok。