Mybatis insert and delete batch operations
When operating the database, you often encounter batch insert and batch delete. It's better to directly execute SQL statements. There will be some problems when using mybatis for batch insert and batch delete. The following describes the use of mybatis for batch insertion and batch deletion.
1. Batch insert
Java code:
XML code
Batch insert SQL statements
Note: value () is a function of MySQL. Please refer to the document function for specific explanation_ values。
The main function is to obtain the value to be updated when the data is repeated.
2. Batch deletion
Java code:
XML code
SQL statement
Note: if the above code is x and Z is the joint primary key, where id in is used in general.
The above is the mybatis insertion and deletion batch operation introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!