Spring事务管理中@Transactional的propagation参数
关于Spring事务管理中@Transactional的其他配置问题,请参看http://deltamaster.is-programmer.com/posts/28488.html。
本文重点讲一讲propagation参数,propagation配置的就是一个事务的传播性问题。
所谓事务传播性,就是被调用者的事务与调用者的事务之间的关系。举例说明。
//in A.java Class A { @Transactional(propagation=propagation.REQUIRED) public void aMethod { B b = new B(); b.bMethod(); } } //in B.java Class B { @Transactional(propagation=propagation.REQUIRED) public void bMethod { //something } }
在上面这个例子中,传播性被设为了REQUIRED,注意,这是默认值,也即不进行该参数配置等于配置成REQUIRED。
REQUIRED的含义是,支持当前已经存在的事务,如果还没有事务,就创建一个新事务。在上面这个例子中,假设调用aMethod前不存在任何事务,那么执行aMethod时会自动开启一个事务,而由aMethod调用bMethod时,由于事务已经存在,因此会使用已经存在的事务(也就是执行aMethod之前创建的那个事务)。
对于这样的配置,如果bMethod过程中发生异常需要回滚,那么aMethod中所进行的所有数据库操作也将同时被回滚,因为这两个方法使用了同一个事务。
MANDATORY的含义是,支持当前已经存在的事务,如果还没有事务,就抛出一个异常。如果上例中aMethod的传播性配置为MANDATORY,我们就无法在没有事务的情况下调用aMethod,因此,传播性为MANDATORY的方法必定是一个其他事务的子事务,当逻辑上独立存在没有意义或者可能违反数据、事务完整性的时候,就可以考虑设置这样的传播性设置。
NESTED的含义是,在当前事务中创建一个嵌套事务,如果还没有事务,那么就简单地创建一个新事务。
REQUIRES_NEW的含义是,挂起当前事务,创建一个新事务,如果还没有事务,就简单地创建一个新事务。
请注意以上两者的区别,大多数情况下一上两种传播性行为是类似的,不过在事务回滚的问题上,以上两者有很大的区别。
首先,REQUIRES_NEW会创建一个与原事务无关的新事务,尽管是由一个事务调用了另一个事务,但却没有父子关系。
如果bMethod的传播性是REQUIRES_NEW,而抛出了一个异常,则bMethod一定会被回滚,而如果aMethod捕获并处理了这个bMethod抛出的异常,那么aMethod仍有可能成功提交。当然,如果aMethod没有处理这个异常,那么aMethod也会被回滚。
如果aMethod在bMethod完成后出现了异常,那么bMethod已经提交而无法回滚,只有aMethod被回滚了。
而对于NESTED,虽然也会创建一个新事务,但是这个事务与调用者是有父子关系的相互依存的。
如果bMethod的传播性是NESTED,而抛出了一个异常,事务的回滚行为与REQUIRES_NEW是一致的。
但是如果aMethod在bMethod完成后出现了异常,bMethod同样也会被回滚。因为事实上,EJB中没有对于NESTED传播性的类似实现,NESTED并不是真正启动了一个事务,而是开启了一个新的savepoint。
NEVER的含义很简单,就是强制要求不在事务中运行,如果当前存在一个事务,则抛出异常,因此如果bMethod传播性是NEVER,则一定抛出异常。
NOT_SUPPORTED的含义是,强制不在事务中运行,如果当前存在一个事务,则挂起该事务。
SUPPORTS的含义是,支持当前事务,如果没有事务那么就不在事务中运行。SUPPORTS传播性的逻辑含义比较模糊,因此一般是不推荐使用的。
Apr 25, 2021 06:22:39 PM
敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw| 粗工| 粗工内容 | 粗工| 粗工内容 |墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|https://mypaper.m.pchome.com.tw/f88tw
Aug 21, 2022 01:49:19 PM
Rajasthan Board Model Paper 2023 Class 1 Pdf Download with Answers for Rajasthani Medium, English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. RBSE Question Paper Class 1 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.
Oct 22, 2023 01:44:06 PM
This is truly an practical and pleasant information for all. Thanks for sharing this to us and more power
Oct 26, 2023 01:43:46 PM
I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc
Oct 26, 2023 02:13:57 PM
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man, Keep it up First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information
Oct 26, 2023 02:34:24 PM
This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want…HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!
Oct 26, 2023 03:09:54 PM
It's amazing. I want to learn your writing skills. In fact, I also have a website. If you are okay, please visit once and leave your opinion. First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information Thank you.
Oct 26, 2023 03:18:00 PM
your mental health is often the most efficient. Because no two weight-loss journeys are alike, we asked a bunch of women who’ve accomplished a major weight loss exactly how they did it
Oct 26, 2023 03:24:01 PM
Excellent read, I just passed this onto a friend who was doing a little research on that. And he actually bought me lunch as I found it for him smile Therefore let me rephrase that: Thank you for lunch.
Oct 26, 2023 03:31:00 PM
really like this post,and i parent that they having a ton of a laugh to peruse this post,they might take a respectable website to make an information,thanks for sharing it to me. First-rate job for publishing this type of useful internet website online. Your internet log isn’t only useful but it's miles moreover clearly creative too "`i like viewing net web sites which recognise the price of handing over the incredible beneficial useful resource freed from rate. I honestly cherished studying your posting. Thanks!
Oct 26, 2023 03:48:27 PM
We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work.
Oct 26, 2023 03:55:41 PM
Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!
Oct 26, 2023 03:56:07 PM
your mental health is often the most efficient. Because no two weight-loss journeys are alike, we asked a bunch of women who’ve accomplished a major weight loss exactly how they did it
Oct 26, 2023 04:06:03 PM
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more
Oct 26, 2023 04:10:46 PM
Many professional gamblers tend to stick to the most well-known online casinos with a good reputation. In fact, this is a very conscious and sound strategy for high rollers as they will only trust their money with the top online casino sites. However, this behaviour may also lead to the paradox of missing out on the biggest new casino bonuses. As a matter of fact, there are plenty of less known casinos out there who actually belong to the same casino network as the more popular ones - while offering better bonuses at the same time!
Oct 26, 2023 04:17:51 PM
I am aware that people like you, are naturally intuitive, resourceful and already have the ability to heal yourself and transform into the person you want to be, you just need assistance to tap into your own resources.
Oct 26, 2023 04:25:20 PM
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more
Oct 26, 2023 04:28:40 PM
I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc
Oct 26, 2023 04:38:50 PM
A lot of people hear all about the lively method you produce advantageous suggestions on the web site and as well as cause response from the others on this issue and my princess is discovering so much. Take advantage of the rest of the new year. You’re doing a brilliant job
Oct 26, 2023 04:39:19 PM
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man, Keep it up First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information
Oct 26, 2023 04:53:09 PM
Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!
Oct 26, 2023 04:56:50 PM
This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want…HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!
Oct 26, 2023 05:22:00 PM
It's amazing. I want to learn your writing skills. In fact, I also have a website. If you are okay, please visit once and leave your opinion. First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information Thank you.
Oct 26, 2023 05:30:38 PM
your mental health is often the most efficient. Because no two weight-loss journeys are alike, we asked a bunch of women who’ve accomplished a major weight loss exactly how they did it
Oct 26, 2023 05:31:48 PM
I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc
Oct 26, 2023 05:39:19 PM
Hello, I'm happy to see some great articles on your site. Would you like to come to my site later? My site also has posts, comments and communities similar to yours. Please visit and take a look
Oct 26, 2023 05:39:47 PM
Decent data, profitable and phenomenal outline, as offer well done with smart thoughts and ideas, bunches of extraordinary data and motivation, both of which I require, on account of offer such an accommodating data her
Oct 26, 2023 05:48:58 PM
Decent data, profitable and phenomenal outline, as offer well done with smart thoughts and ideas, bunches of extraordinary data and motivation, both of which I require, on account of offer such an accommodating data her
Oct 26, 2023 05:57:07 PM
I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that. First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information
Oct 26, 2023 06:00:39 PM
This is a great article, Given such a great amount of information in it, These kind of articles keeps the clients enthusiasm for the site, and continue sharing more … good fortunes.Click Here
Oct 26, 2023 06:26:25 PM
really like this post,and i parent that they having a ton of a laugh to peruse this post,they might take a respectable website to make an information,thanks for sharing it to me. First-rate job for publishing this type of useful internet website online. Your internet log isn’t only useful but it's miles moreover clearly creative too "`i like viewing net web sites which recognise the price of handing over the incredible beneficial useful resource freed from rate. I honestly cherished studying your posting. Thanks!
Oct 26, 2023 06:41:47 PM
Excellent read, I just passed this onto a friend who was doing a little research on that. And he actually bought me lunch as I found it for him smile Therefore let me rephrase that: Thank you for lunch.
Oct 26, 2023 06:44:01 PM
Your personal dedication to passing the solution all around has been certainly advantageous and have constantly allowed those like me to get to their objectives. Your amazing helpful hints and tips denotes a whole lot to me and additionally to my colleagues. Thanks a ton; from all of us. Thank you for all of the hard work on this web site.
Oct 26, 2023 06:50:51 PM
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it! After reading your article I was amazed.
Oct 26, 2023 06:56:44 PM
A lot of people hear all about the lively method you produce advantageous suggestions on the web site and as well as cause response from the others on this issue and my princess is discovering so much. Take advantage of the rest of the new year. You’re doing a brilliant job
Oct 26, 2023 07:08:28 PM
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it! After reading your article I was amazed.
Oct 26, 2023 07:11:49 PM
Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!
Oct 26, 2023 07:27:47 PM
Many professional gamblers tend to stick to the most well-known online casinos with a good reputation. In fact, this is a very conscious and sound strategy for high rollers as they will only trust their money with the top online casino sites. However, this behaviour may also lead to the paradox of missing out on the biggest new casino bonuses. As a matter of fact, there are plenty of less known casinos out there who actually belong to the same casino network as the more popular ones - while offering better bonuses at the same time!
Nov 06, 2023 10:08:03 PM
hi sir you have written a very important something. I like your every point you dropped
Nov 06, 2023 10:22:56 PM
this is really good website, coolest I have ever visit thank you so much, i will follow and stay tuned much appriciated
Nov 07, 2023 03:18:35 PM
Thanks for sharing this informative information with us. GOOD works!
Nov 07, 2023 08:39:50 PM
They can be tips related to numerous composition categories, including college applications and complex assignments like Kaplan assignment help
Nov 08, 2023 05:36:00 PM
처음으로 여기를 방문하고 블로그에서 흥미로운 내용을 많이 발견했습니다. 특히 토론입니다. 감사합니다.
Nov 09, 2023 01:47:23 PM
The post is written in very a good manner and it contains many useful information for me
Nov 09, 2023 01:51:55 PM
나는이 웹 사이트에있는 당신의 몇몇 포스트를보고 있었다. 그리고 나는이 웹 사이트가 정말로 유익하다고 생각한다! 계속 ..
Nov 09, 2023 04:12:50 PM
Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work
Nov 09, 2023 05:56:49 PM
I would like to thank you for the efforts you have put in writing this Magic Mesh Door Coverblog. I'm hoping the same high-grade blog post from you in the future also. Actually your creative writing abilities has inspired me to get my own screen door instant website going now. Actually blogging is spreading its wings and growing fast. Your write up is a great example
Nov 09, 2023 06:52:24 PM
I think about it is most required for making more on this get engaged
Nov 09, 2023 07:50:08 PM
You have observed very interesting points ! ps decent internet site .
Nov 09, 2023 08:42:33 PM
This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
Nov 12, 2023 05:04:10 PM
훌륭하게 작성된 기사, 모든 블로거가 동일한 콘텐츠를 제공한다면 인터넷이 훨씬 더 나은 곳이 될 것입니다 ..
Nov 13, 2023 04:44:46 PM
"귀하의 게시물을 읽어 주셔서 정말 기쁩니다. 제가 찾고있는 정보가 가득하며" "귀하의 게시물 내용이 굉장합니다" "라는 코멘트를 게시하는 것을 좋아합니다. 훌륭합니다.
Nov 14, 2023 02:31:43 PM
Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine. <a href="https://툰코주소.net/">툰코</a>
Nov 14, 2023 07:25:29 PM
완전히 흥미로운 블로그 게시입니다. 저는 종종 Diwali Bumper Lottery에 대한 내 프로젝트의 도움을 위해 귀하의 게시물을 방문하고 귀하의 슈퍼 쓰기 기능은 진정으로 당황스러워했습니다.이 게시에 대해 많이 감사합니다.
Nov 15, 2023 04:43:12 PM
Personally I think overjoyed I discovered the blogs.
Nov 16, 2023 09:52:46 PM
I would like to thank you for the efforts you have put in writing this Magic Mesh Door Coverblog. I'm hoping the same high-grade blog post from you in the future also. Actually your creative writing abilities has inspired me to get my own screen door instant website going now. Actually blogging is spreading its wings and growing fast. Your write up is a great example
Dec 14, 2023 06:00:03 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Dec 28, 2023 07:11:14 PM
I think I have never seen such blogs ever before that has complete things with all details which I want. So kindly update this ever for us
Jan 07, 2024 03:35:34 PM
최악의 부분은 소프트웨어가 간헐적으로 만 작동하고 데이터가 정확하지 않다는 것입니다. 정보가 올바르지 않으면 발견 한 내용에 대해 누구와도 대면 할 수 없습니다.
Jan 11, 2024 02:24:42 PM
최악의 부분은 소프트웨어가 간헐적으로 만 작동하고 데이터가 정확하지 않다는 것입니다. 정보가 올바르지 않으면 발견 한 내용에 대해 누구와도 대면 할 수 없습니다.
F
Jan 16, 2024 05:20:54 PM
방문자에게 제공하는 최고 품질의 정보를 정말로 즐겼다 고 말하기 전에 웹 사이트를 떠날 수 없었습니까? 새로운 게시물을 확인하기 위해 자주 다시 올 것입니다.
Jan 16, 2024 09:17:31 PM
귀하가 게시 한 정보는 매우 유용합니다. 추천 한 사이트가 좋았습니다. 공유 해주셔서 감사합니다
Jan 28, 2024 10:51:31 PM
I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well
Jan 31, 2024 06:33:53 PM
Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it.
Feb 01, 2024 03:47:08 PM
Superb article. Thanks to this blog my expedition has actually ended
Feb 01, 2024 06:44:13 PM
이 기사는 기사 역사상 최고 중 하나입니다. 나는 골동품 'Article'수집가이고 때때로 그것들을 흥미롭게 읽습니다.
Feb 01, 2024 08:58:18 PM
This blog really convinced me to do it! Thanks, very good post
Feb 01, 2024 10:45:40 PM
You got a very fantastic website, Gladiolus
Feb 03, 2024 03:48:58 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 04:14:08 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 04:31:20 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 04:53:39 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 03, 2024 05:33:24 PM
hi there! I just desire to deliver a significant thumbs up with the brilliant records you could have here for this publish. I am returning in your weblog for more soon. Have you ever concept approximately writing an ebook or guest authoring on different websites? I've a weblog focused on the equal thoughts you speak and would like to have you ever percentage a few testimonies/data. I realize my audience would revel in your work. In case you are even remotely involved, sense free to shoot me an electronic mail. Wow!, this become a pinnacle exceptional submit. In concept i’d want to post like this as nicely – taking time and real effort to make a nice article… but what am i able to say… i hold putting it off and in no way seem to get some thing executed
Feb 03, 2024 05:54:52 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 06:17:25 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 06:34:48 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 07:13:39 PM
아주 좋은 블로그 게시물. 다시 한 번 감사드립니다. 멋있는.
Feb 03, 2024 07:55:13 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 03, 2024 08:14:33 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 08:36:22 PM
아주 좋은 블로그 게시물. 다시 한 번 감사드립니다. 멋있는.
Feb 03, 2024 08:57:07 PM
Here at this site extremely the critical material accumulation so everyone can appreciate a great deal
Feb 03, 2024 08:58:23 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 09:18:54 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 03, 2024 09:42:17 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 04, 2024 02:50:45 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 04, 2024 03:08:11 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 04, 2024 03:36:44 PM
아주 좋은 블로그 게시물. 다시 한 번 감사드립니다. 멋있는.
Feb 04, 2024 03:52:56 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 04, 2024 04:04:21 PM
시간을내어이 문제에 대해 토론 해 주셔서 감사합니다.이 주제에 대해 더 많이 배우고 싶습니다. 가능하다면 전문 지식을 얻으면 추가 정보로 블로그를 업데이트 해 주시겠습니까? 저에게 매우 도움이됩니다.
Feb 04, 2024 04:17:23 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 04, 2024 04:39:03 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 04, 2024 05:07:49 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 04, 2024 05:31:54 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 04, 2024 05:58:06 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 04, 2024 07:06:39 PM
유익한 웹 사이트를 게시하는 데 아주 좋습니다. 웹 로그는 유용 할뿐만 아니라 창의적이기도합니다.
Feb 04, 2024 08:03:44 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 05, 2024 09:26:08 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다
Feb 06, 2024 03:51:43 PM
아주 좋은 블로그 게시물. 다시 한 번 감사드립니다. 멋있는.
Feb 08, 2024 06:47:41 PM
흠 !! 이 블로그는 정말 멋져요. 정말 운이 좋아 여기에 도달해서 멋진 정보를 얻었습니다