究竟是什么“Propagation.REQUIRES_NEW"?意味着使用Spring事务管理? [英] what exactly "Propagation.REQUIRES_NEW" means using Spring transaction management?

查看:29
本文介绍了究竟是什么“Propagation.REQUIRES_NEW"?意味着使用Spring事务管理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此事的困惑是,我们如何使用先前创建的事务?或者换句话说,一个事务可能与多少个线程相关?

my confusion related to this matter is that how we can use a previously created transaction? or in other words how many threads a transaction could be related to?

推荐答案

一个事务在 spring 中只能与一个线程相关.好吧,通过一些努力,您可以使它成为一个长期运行的事务,但这是一种反模式,afaik.

A transaction can be related to only one thread in spring. Well, with some effort you can make it a long-running transaction, but that's an anti-pattern afaik.

REQUIRES_NEW 表示每当程序流进入带注释的方法时,无论现有事务如何,都会启动一个新事务.

REQUIRES_NEW means that whenever the program flow enters the annotated method, a new transaction will be started regardless of any existing transaction.

REQUIRED 表示将重用现有事务,或者如果没有现有事务,则将启动新事务.

REQUIRED means that an existing transaction will be reused, or if there's no existing transaction a new one will be started.

这篇关于究竟是什么“Propagation.REQUIRES_NEW"?意味着使用Spring事务管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆