---
title: "Comment by HyeongSu on \"Implementing Automatic Retry for Database Deadlocks in Spring Boot using Spring Retry\" | Hashnode"
description: "Thanks to you, I was able to contemplate about lock and isolation. In source code, you implemented the @Transactional annotation in the Repository Interface, bu"
url: "https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1/comment/65a6446acd3d656b75b71db5"
---

[Discussion](https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1)

Comment [Implementing Automatic Retry for Database Deadlocks in Spring Boot using Spring Retry](https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1)

[HyeongSu](https://hashnode.com/@amecoder)

[Jan 16, 2024](https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1/comment/65a6446acd3d656b75b71db5)

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…](https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative/annotations.html#:~:text=The%20Spring%20team,a%20rollback%20scenario.)

\---- 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.

[Taehyeong Lee](https://hashnode.com/@jsonobject)

[Jan 16, 2024](https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1/comment/65a6446acd3d656b75b71db5#reply-65a66e84094772a9b1b2db89)

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.
