Re:Best Practices for Testing in Java (2019)
by nytgop77 on Wednesday September 02, 2020 @01:35AM
(#24350276)
is database access only in service?
[ Parent
| on HN ]
Re:Best Practices for Testing in Java (2019)
by exabrial on Wednesday September 02, 2020 @08:43AM
(#24352633)
Correct. A business logic controller can not directly corner the outside world, it must talk through a service.
This is nice because it prevents leaky abstractions into the controller layer. Actions across services that need to be atomic can be grouped in an XA transaction:
// Xa start databaseService.reset password(user); emailService.notifyPasswordChange(user); // Xa commit