• mybatis delete 返回-2147482646的问题


    在用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。

  • 相关阅读:
    LeetCode-Read N Characters Given Read4 II
    LeetCode-One Edit Distance
    LeetCode-Palindrome Permutation II
    LeetCode- Longest Absolute File Path
    LeetCode-Strobogrammatic Number II
    LeetCode-Strobogrammatic Number
    LeetCode-Flatten 2D Vector
    LeetCode-Shortest Word Distance III
    LeetCode-Shortest Word Distance II
    Cookie/Session
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/12291624.html
Copyright © 2020-2023  润新知