banking-kata-java icon indicating copy to clipboard operation
banking-kata-java copied to clipboard

Use of Transaction

Open valentinajemuovic opened this issue 2 years ago • 1 comments

Discussed in https://github.com/valentinacupac/banking-kata-java/discussions/54

Originally posted by ldauvilaire August 23, 2022 Storage (i.e. Database) transactions have to be managed or else data integrity can be broken in case of access in parallel.

The use cases : DepositFundsUseCase and WithdrawFundsUseCase shall use only one transaction (read and update done into the same transaction). The current code is using 2 (implicit) transactions, one for reading (repository.findRequired(accountNumber)) and another one for updating (repository.update(bankAccount)), this would not work in a "real" bank.

Of course the @Transactional shall not be implemented into the domain but into driven port(s). May be a "TransfertFund" from one account to another would help to show the problem in evidence.

valentinajemuovic avatar Dec 30 '22 10:12 valentinajemuovic