在哪里放@Transactional?在接口规范或实现中?

编程入门 行业动态 更新时间:2024-10-27 07:15:43
本文介绍了在哪里放@Transactional?在接口规范或实现中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

放置 @Transactional 注释时,最佳做法是什么?我应该注释接口方法还是实现?

What is considered the best practice in placing the @Transactional annotation? Should I annotate the interface method or the implementation?

推荐答案

好问题。我总是把它放在实施中。也许是因为它是一个实现细节,而不是一个抽象。

Good question. I've always put it in the implementation. Perhaps because it is an implementation detail, rather than an abstraction.

您可能希望不同的实现具有不同的交易行为。

You may want different implementations to have different transactional behaviours.

El Guapo指出,除此之外,与代理策略相关的接口可能会产生更多问题。

El Guapo noted that, in addition to that, there are more issues that can arise from putting on on the interface, related to the proxying strategy.

更多推荐

在哪里放@Transactional?在接口规范或实现中?

本文发布于:2023-10-07 17:10:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469984.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   Transactional

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!