Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Transaction Isolation & Propagation Levels

 
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some doubts regarding the Transactions Propagation & Isolation levels. Consider the code snippet below:



I have below doubts:

1. Where we need to put the Propagation levels: On method m1 or m2? I hope it needs to be on m2?
2. Can we place propagation level on both the methods as well? I hope it can't be on m1?
3. Where we can put the isolation levels? I think it needs to be placed on just one method and it will be applicable to that method only, please correct me if I am wrong.
 
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TX isolation and propagation are DB concepts, not so much Java concepts. Start by analyzing the concurrency of your multi-user application, and balance that against the need for speed. It may well turn out that you do not need to worry at all. In my 20+ years of professional work with DB-based Java apps I haven't had to consider this issue much. Why do you think you need to?
 
Vaibhav Gargs
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim.

I am going through the spring transactions and there is so much emphasis on these concepts there. I am just thinking if it can be handled at DB side then why there is a provision of these on java APIs.

And I can understand that isolation can be handled at DB side but just unable to grasp that propagation can be handled at DB side since it is a related to one method rivalling another method and transaction boundaries withinmethods I may be wrong because I am not an expert.
 
Tim Moores
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

since it is a related to one method rivalling another method


No. Where did you get this idea? Again: TXs are a DB concept, not a Java concept. The fact that there are Java methods to control them (which map through to DB calls) does not change that.
 
Vaibhav Gargs
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim. Can you please help me understand how propagation occurs at DB level. We run the SQL queries separately, so, how they can overlap each others' calls?
 
Marshal
Posts: 25671
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine two users connecting to your system and executing transactions at about the same time. They are both going to be accessing the database at about the same time, possibly overlapping. That's why you need transactions.
 
Vaibhav Gargs
Ranch Hand
Posts: 431
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul. As per my understanding, in this scenario, transaction isolation levels will play a significant role. I am unable to understand how Propagation levels come into picture at DB level.
 
Paul Clapham
Marshal
Posts: 25671
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never heard of propagation levels before. So I did some web-searching and it appears to me that they are entirely a Spring invention.

So I did some more web-searching and came up with the Spring documentation about Transaction Management. I expect that should answer your questions.
 
See where your hand is? Not there. It's next to this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic