[英]How to use different spring transactions for different methods
I am having a problem with the persistence of a method that is calling another methods to do persistence at my oracle db.我在我的 oracle 数据库中调用另一种方法来执行持久性的方法的持久性存在问题。
I will try to explain as better as i can to make more easy to you guys, I hope that you can help me.我会尽力解释得更好,让你们更容易,我希望你们能帮助我。
This is my scenario.这是我的场景。
I have a component, in which i am calling a method that looks like that:我有一个组件,我在其中调用一个看起来像这样的方法:
public void execute() throws Exception {
service1.method1(); // @Transactional
service2.method2(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
service3.method3(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
}
The thing is that i need to persist every method separately in case that one of them gets an exception, the others could be persisted.问题是我需要分别保留每个方法,以防其中一个出现异常,其他方法可以保留。
Right now the problem i have is that i am having a deadlock and my code stills running until i stop my application, and the transactions never end.现在我遇到的问题是我遇到了死锁,我的代码仍在运行,直到我停止我的应用程序,并且事务永远不会结束。
I tried so many things, but i am trying without the needed knowledge to work with this spring transactions and i do not know what more i can try to do.我尝试了很多东西,但我在没有必要的知识的情况下尝试使用此 spring 事务,我不知道我还能尝试做什么。
Can you bring me some light on this dark hole where i am right now?你能为我现在所在的这个黑洞带来一些启示吗?
Really, thank you.真的很谢谢你。
Spring AOP same class method will not works. Spring AOP 相同的 class 方法将不起作用。 this.method1(); this.method1(); // @Transactional will not work. // @Transactional 将不起作用。
more explanation in this thread Same class invoke NOT effective in Spring AOP cglib此线程中的更多解释相同的 class 调用在 Spring AOP cglib 中无效
u can register different transactionManager, and ur services use its @Transactional(tx="xxx")你可以注册不同的事务管理器,你的服务使用它的@Transactional(tx="xxx")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.