---
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 think deeply about lock and isolation. Thank you! You have set the @Transactional annotation on the Repository interface. I usually"
url: "https://hashnode.com/posts/implementing-automatic-retry-logic-for-database-deadlocks-in-spring-boot-using-spring-retry/65a625f497a98f4d89f778b1/comment/65a64c5368bd11c4ade3b79e"
---

[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/65a64c5368bd11c4ade3b79e)

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?

[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/65a64c5368bd11c4ade3b79e#reply-65a66add84f4ade3e636a37d)

Of course, it is most commonly used in concrete classes at the Service level :) In this example, I wanted to introduce you to the lowest level where you can use @Transactional in your project, so I showed you an example of specifying it in the @Repository interface. I make it a habit to specify @Repository and @Service, because that way I can cope with both transactions from real-time APIs with low execution time, and logic that has hours of execution time and intentionally doesn't use service-level transactions.

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

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

[Taehyeong Lee](https://hashnode.com/@jsonobject) Thank you for the response. I also plan to develop a habit of doing so. By establishing a solid foundation, it seems possible to preemptively prevent deadlocks that may occur in unexpected areas.
