
Thanks to you, I was able to contemplate about lock and isolation.
In source code, you implemented the @Transactional annotation in the Repository Interface, but according to Spring documentation, they recommend setting it at the class level.
how do you think about it?
docs.spring.io/spring-framework/reference/data-ac…
---- I discovered this after making the comment ---- It seems that the Repository with Data JPA interface is an exception where it's permissible to use Transactional.
It also works well to specify @Transactional in a custom method of the Spring Data JPA interface, as in this example. This brings a lot of convenience to the developer, as they don't have to re-write each custom query with @Transactional in an outer contained class. In typical real-time business logic, most of the time the transaction propagation setting will use the default value of Propagation.REQUIRED, so you can also naturally carry over transactions created at higher Service levels.
Unknown
Backend Developer
Thanks to you, I was able to think deeply about lock and isolation. Thank you!
You have set the @Transactional annotation on the Repository interface. I usually prefer to declare it in the Class method of the Service layer... Is it a better practice to declare it in the Repository?