Why I am getting deadlock in this code?
I tried to debug it and also read many article about deadlock prevention but could not get this. I have used synchronization, to make thread safe a block of code on the basis of `accountNumber`.
I am getting this `Transaction` object from an API and I want to lock my code on the basis of what the `Transaction` object contain. `Transaction` object contains info like debit/credit account number, amount etc.
Two threads should not be executed `executeTransaction` method simultaneously if there is any common `accountNumber` between them.
Here, `lockedAccount` is storing all accounts that are currently locked and two methods for locking and unlocking an `accountNumber`.
DAO / Repository layer.
for more information ,
my **accountDetails** table in database have three columns,
this is Service layer
where i am using `@Transactional` annotation for `executeTransaction` method.
but i am getting database deadlock in this code.
below is my error.