Mybatis annotation method, how to implement MySQL, after update, return the updated value

as shown in the title, the stupidest way is to write a modification statement first, and then write a query statement, but it is a waste of resources to connect to the database frequently

based on Mybatis, can @ Update be implemented, and the return value is the changed target value, or, like @ Insert, add @ option or something, and return the inserted data as an entity class

Apr.10,2022

  1. if you look at the source code of mybatis, you will find that mybatis implements the update operation in this way
  

you just call it in a transaction.
what you are worried about is that two statements use two connections. The statements you execute in a transaction are all under one connection

.
Menu