Multiple threads update same row in database at a time how to maintain consistence

后端 未结 5 1558
既然无缘
既然无缘 2021-01-14 04:19

In my java application multiple threads update same row at a time how to get consistence results ?

for example

current row value count =0; 
thread 1          


        
5条回答
  •  自闭症患者
    2021-01-14 05:18

    There are two possible ways to go.

    • Either you choose a pessimistic approach and lock rows, tables or even ranges of rows.

    • Or you work with versioned Entities (Optimistic Locking).

    Maybe you can will find more information here:

    https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/transactions.html

提交回复
热议问题