Closed subratrout closed 7 years ago
They're the same snippets. Definitely a mistake in the material.
Hello,
With CSB-2017 : Part-Two still with such snippet
@Transactional
public void bankTransfer(Long fromAccount, Long toAccount, Integer amount) {
Account from = accountRepository.findOne(fromAccount);
Account to = accountRepository.findOne(toAccount);
from.setBalance(from.getBalance() - amount);
to.setBalance(to.getBalance() + amount);
}
with both places (where is expected and where is not).
Does it should be with changes in the material about second situation (where is not expected):
If the method would not have been annotated with the @Transactional annotation, the accounts would have to be separately saved if we want to commit the changes to the database.
?! with drop annotation and with addition something like:
accountRepository.save(from); accountRepository.save(to);
Thanks! @nygrenh
If the method would not have been annotated with the @Transactional annotation, the accounts would have to be separately saved if we want to commit the changes to the database.
I practically see no difference between both codes. What I am missing here?