1
I was studying a little bit on the note @Transactional (version made by Spring), and I came up with a doubt. According to a published in Devmedia, to "more correct form" to use is to write down in our business method, because there can be several shares in the bank, and not only one in specific. So I thought to myself, if in my Restfull application, it would no longer be feasible to write down the endpoint logo (which only makes the one method call) to make a transaction of everything you have from there on. Example:
@PostMapping
@Transactional(propagation = Propagation.REQUIRED)
public Response< ? > criarNovaViagem(@RequestBody ViagemRequest novaViagem) throws ViagemServiceApplicationException {
return new Response<>(true, this.viagemService.criarViagem(novaViagem), null);
}
This method "criarNovaViagem()
" does n operations on N different tables. It’s wrong or "pig" I jot down my endpoint with @Transacional
?