MyBatis execution Update Returns a negative number of rows

Source: Internet
Author: User

Gets the number of update rows for the MyBatis and always returns negative numbers. Later on the official network to find the reason, is due to Defaultexecutortype, Defaultexecutortype has three actuators simple, reuse and batch. Where batch can cache SQL for bulk update operations to improve performance, there is a flaw in the inability to get update, the number of rows returned by delete. The default actuator for Defaultexecutortype is simple.

name Description
Simple Actuators Execute other statements
Reuse Prepared statements statements may be used repeatedly
BATCH Statements and batch updates can be executed repeatedly



Because batch executor is enabled in the project configuration, the number of rows returned by update and delete is lost, and the actuator is changed to simple.

<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd" > <configuration>    <settings>        <!--Global Mapper Enable cache --        <setting name="cacheenabled" value="true" />        < when!--query, close the associated object for immediate loading to improve performance--        <setting name="lazyloadingenabled" value="true" / >        <!--Set the shape of the associated object load, where the field is loaded on demand (the Load field is specified by SQL) and all fields of the associated table are not loaded to improve performance --        <setting name="aggressivelazyloading" value="false" />         <!--for unknown SQL queries, allowing different result sets to be returned to achieve a common effect--        <setting name="multipleresultsetsenabled" value="true" />        <!--allow column labels to be used instead of column names --        <setting name="Usecolumnlabel" value="true" />         <!--allows you to use a custom primary key value (such as a program-generated UUID 32-bit encoding as the key value), and the PK generation strategy for the data table will be overwritten -        <setting name="Usegeneratedkeys" value="true" />        <!--given nested resultmap with field-property mapping support-        <setting name="Automappingbehavior" value="full" / >        <!--cache SQL for bulk update operations to improve performance --        <!--Defaultexecutortype set to batch has a flaw in the inability to get update, the number of rows returned by Delete--        <!--<setting name= "Defaultexecutortype" value= "BATCH"/>-->        <!--The database is still not responding for more than 25,000 seconds timeout -        <setting name="Defaultstatementtimeout" value="25000" />         <!--Log ---        <!--<setting name= "Logimpl" value= "slf4j"/> --    </Settings>    <!--register MyBatis plugins--    <plugins>        <!--mysql Paging plugin--        <plugin Interceptor="Com.rvho.mybatis.interceptor.MybatisPageInterceptor">             < property name="DatabaseType" value="mysql"/>        </plugin>    </plugins></configuration>

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MyBatis execution Update Returns a negative number of rows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.