|
Optimistic locking has now been enabled for savings accounts.
The same can be tested as follows:
Locate the following code snippet (currently line number 88,89) in method handleWithdrawal(...) of SavingsAccountDomainServiceJpa.java and add breakpoints on both lines.
saveTransactionToGenerateTransactionId(withdrawal);
this.savingsAccountRepository.save(account);
Next trigger a withdrawal request , Ex: https://localhost:8443/mifosng-provider/api/v1/savingsaccounts/1/transactions?command=withdrawal with json body
{"transactionDate":"02 December 2014","transactionAmount":"100","locale":"en","dateFormat":"dd MMMM yyyy"}
You can then let this thead (request 1) to now proceed to the second breakpoint. Trigger another requests (request 2) which pauses at break point 1
Let request 1 proceed to completion. Now, let request 2 proceed, it should fail with an exception similar to
Object of class [org.mifosplatform.portfolio.savings.domain.SavingsAccount] with identifier [1]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [org.mifosplatform.portfolio.savings.domain.SavingsAccount#1]
|