Does spring declarative transaction provide the implementation of pessimistic lock and optimistic lock?

problem description

I have read a lot of articles on the Internet, and they all say that optimistic locks are generally the way to add version fields and use CAS. However, we all know that it is very troublesome to implement this solution in a project without the transaction propagation mechanism of Spring declarative transactions. Because this means that it can only be implemented by programmers themselves, and every time you write a update, you have to consider this problem. There is no online article saying that Spring"s declarative transactions support this.

Jul.20,2021

spring is not clear, but I am using the mybatis interceptor to implement optimistic locks. No per-update processing is required.


the problem is very bad. I don't know if it's because I'm not up to standard or because some subject hasn't stated it clearly. Spring certainly doesn't provide pessimistic lock , optimistic lock . At the same time, I don't know why Spring's declarative transaction and the inevitable connection between these two locks. Declarative transaction only simplifies programmer's transaction. As for the implementation of the lock, you still have to implement it, and you still have to write sql. Are you know?

Menu