In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how MyBatis-Plus inserts data in batches, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In the spring boot+mybatis plus environment, a single insert uses the insert method that comes with BaseMapper.
Public ApiResult addAnc (Anc anc) {ApiResult result = new ApiResult (); Integer insert = ancMapper.insert (anc); if (insert < 1) {return result.failed ("publish failed, please contact the administrator");} return result.success (anc)
BaseMapper does not provide a bulk insert interface, but it does in com.baomidou.mybatisplus.service.IService
/ *
* insert (batch), this method is not suitable for Oracle *
* * @ param entityList entity object list * @ return boolean * / boolean insertBatch (List entityList); / *
* insert (batch) *
* * @ param entityList entity object list * @ param batchSize insert batches * @ return boolean * / boolean insertBatch (List entityList, int batchSize)
Using methods, define your own interface, inherit IService, and generalize to the manipulated entity class
@ Servicepublic interface WorkIService extends IService {}
Define an implementation class to implement the appeal interface
@ Servicepublic class WorkIServiceImpl extends ServiceImpl implements WorkIService {}
Where WorkMapper is the mapper of normal operation
Test bulk insert operations in the business
List entityList = new ArrayList (1000); for (int item1)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.