Oracle + mybatis implements batch insert, update and delete sample code
preface
Mybatis is a very common data persistence framework in Web engineering development. Through this framework, we can easily add, delete, modify and query the database. When a transaction is committed by a database connection, more resources need to be consumed. If more updated data needs to be inserted, and only one data is submitted for each transaction, it will cause a great waste of database resources, resulting in a significant decline in database performance and system performance.
For the batch insertion of mybatis, most of the online examples are about MySQL database, and there are few examples about Oracle database. This article will introduce the contents related to batch insert, update and delete of Oracle + mybatis. I won't say much below. Let's take a look at the detailed introduction together.
1. Insert
(1) The first method: use the < foreach > tag to generate virtual data from the list set of input parameters through union all, so as to realize batch insertion (verified)
Note: the input parameter must be a list set, and there are no values in the SQL statement;
(2) The second way is to use stored procedures to realize batch insertion (verified)
Note: the input parameter is still a list set, and there are values in SQL. The essence is to use stored procedures to realize batch insertion;
(3) The third way: use special SQL statements (found on the Internet and to be verified)
Reference blog: http://blog.csdn.net/w_y_t_/article/details/51416201
The following SQL statement can realize batch insertion of a statement!
Note: when the size of the list is greater than 500, it will fail;
2. Renew
(1) The first way: also use stored procedures (online search, or the blog above)
(2) The second way: using conditional implementation (verified)
Note: you can also use the conditional implementation of or, similar to the SQL deleted below;
3. Delete
Similar to updating the second method
summary
The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.