javamybatistoplink

Does myBatis provide some method such as refreshAndLock?


I'm new to mybatis, I want to know does mybatis provide some method such as refreshAndLock like toplink? How can I make sure that the record I select can't be modified by other thread.


Solution

  • mybatis does not have such method. mybatis is too low level for this. You need to do that manually.

    For pessimistic locking this would look like this:

    <select id="refreshAndLock" resultType="YourType"> SELECT * FROM TableStoringYourType WHERE id = #{id} FOR UPDATE </select>