Seata transactions currently support some functions of the DML syntax of INSERT, UPDATE, and DELETE. These types have been verified by the Seata open source community. The scope of SQL support is still expanding, and it is recommended to use it within the limits of this article. If you are interested in helping the community support more types of SQL, please submit a PR.
// use JdbcTemplate
public void batchUpdate() {
jdbcTemplate.batchUpdate(
"update storage_tbl set count = count -1 where id = 1",
"update storage_tbl set count = count -1 where id = 2"
);
}
// use Statement
public void batchUpdateTwo() {
statement.addBatch("update storage_tbl set count = count -1 where id = 1");
statement.addBatch("update storage_tbl set count = count -1 where id = 2");
statement.executeBatch();
}