春季交易管理员;什么意思是NewTransaction()?

发布于 2025-02-10 20:59:28 字数 621 浏览 1 评论 0原文

我正在将传统应用程序转换为Spring-boot。对于API实施,我想用@transactional注释它,但需要实现自定义的TransactionManager。

当我定义时:

@Component 
public class MyTransactionManager implements PlatformTransactionManager { ... }

接口platformTransActionManager需要实现三种方法...

commit() and and rollback()很明显。

但是getTransaction()应返回类型trassactionstatus 使用方法boolean isNewTransaction()

此返回值的目的到底是什么? 何时应该返回true vs false

如果我没有嵌套交易,可以始终返回true吗? (或总是错误的?)

I am converting a legacy application to spring-boot. For the API-implementation I want to annotate it with @Transactional, but need to implement a custom transactionManager.

When I define:

@Component 
public class MyTransactionManager implements PlatformTransactionManager { ... }

the interface PlatformTransactionManager requires three methods be implemented...

commit() and rollback() are obvious.

But getTransaction() should return a type TransactionStatus
with a method boolean isNewTransaction()

What exactly is the purpose of this return value?
When should it return true vs false?

If I have no nested transaction, is it OK to always return true? (or always false?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文