When I encountered a problem during data insertion and update, I made a transaction: @ TransactionpublicvoidinsertOrUpdate (entity) {Objectosearch (entity); if (o! Null) update (entity); elseinsert (entity);} the pseudo code above is normal in a non-concurrent state. However, when concurrency occurs, multiple identical data records will be inserted. if you increase the isolation level for control, the following message will be displayed: Deadlockfoundwhentryingtogetl... mysql concurrent transaction
When inserting and updating data, I encountered a problem and made a transaction:
@ Transaction
Public void insertOrUpdate (entity ){
Object o = search (entity );
If (o! = Null)
Update (entity );
Else
Insert (entity );
}
The above pseudo code is normal in a non-concurrent state. However, when concurrency occurs, multiple identical data records are inserted. if you increase the isolation level for control, the following message is displayed:
Deadlock found when trying to get lock; try restarting transaction
Solutions