【问题标题】:How to use different spring transactions for different methods如何为不同的方法使用不同的spring事务
【发布时间】:2022-07-29 09:05:02
【问题描述】:

我遇到了一个方法的持久性问题,该方法正在调用另一个方法以在我的 oracle 数据库中进行持久性。

我会尽量解释得更好,让大家更容易理解,希望你能帮助我。

这是我的场景。

我有一个组件,我在其中调用一个看起来像这样的方法:

public void execute() throws Exception {
    this.method1(); // @Transactional
    this.method2(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
    this.method3(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
}

问题是我需要分别持久化每个方法,以防其中一个发生异常,其他方法可以持久化。

现在我遇到的问题是我遇到了死锁,我的代码仍在运行,直到我停止我的应用程序。

我尝试了很多东西,但我在尝试没有必要的知识来处理这个春季交易,我不知道我还能尝试做什么。

你能为我现在所在的这个黑洞带来一些启示吗?

真的,谢谢。

【问题讨论】:

    标签: java spring spring-boot jpa transactions


    【解决方案1】:

    Spring AOP 相同的类方法将不起作用。 this.method1(); // @Transactional 将不起作用。

    更多解释在这个线程Same class invoke NOT effective in Spring AOP cglib

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-08
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多