Matters needing attention when adding batches

    Here is mainly the logic of adding batches of disks, not the code.

    When you need to add new data to the database, you will inevitably encounter adding multiple pieces of data.

    Speaking of this, let's talk about what others have done before, and write a for loop to traverse the new data. In this way, the dry effect can be achieved, but it will take up a lot of database resources. The reason is that when a new piece of data is added, the database connection will be opened and closed once. If the user operates frequently or the amount of data is huge, this is very unfriendly.

    A friendly approach is to fill the data into a list collection, and implement the loop insertion operation through the foreach tag of mybatis. This will only open the database connection once, and close the database connection after adding all the data.

    In contrast, the first approach is simply unbearable.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326484421&siteId=291194637