• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Understanding Propagation Required and Nested scnearios

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through http://static.springsource.org/sprin...tx-propagation But got bit confused. So though of clearing the understanding with below scenarios. Please let me know if below understanding is correct?

Class MyClass1{

//Propagation is Propagation required
public void method1();
{

method1A();
method1B();
MyClass2 myClass2= getBean("MyClass");
myClass2.method2A();
myClass2.method2B();
}


// No porapgation is defined here so default will be reuired
public method1A()
{
//Some Transaction
}


// No porapgation is defined here so default will be reuired
private method1B()
{
//Some Transaction
}

}



Class MyClass2{

//Propagation is Propagation required
public void method2();
{

method2A();
method2B();
}


// No porapgation is defined here so default will be required
public method2A()
{
//Some Transaction
}


// No porapgation is defined here so default will be required
public method2B()
{
//Some Transaction
}

}


Now here are the scenarios

we call the method1() of MyClass1 inside main method



Scenarion1:-

No exception occurs. transaction will be created before method1A() and will be commited after myClass2.method2B(); Right?



Scenarion2:-

Runtime exception occurs during method1B. Complete transaction will be rolled back. Right?




Scenarion3:-

Runtime exception occurs during method2A(Transaction under method2A will be treated as part of transaction created
under method1 in class1) .Complete transaction will be rolled back. Right?



Scenarion4:-

Runtime exception occurs during method2B(Transaction under method2A will be treated as part of transaction created
under method1 in class1) .Complete transaction will be rolled back. Right?

-------------------------------------------------------------------------------------------------------


Now if we consider the same scenarios with propagation as Nested for methods method2A and method2B.



Scenarion1:-

No exception occurs. transaction will be created on entering method1A() and will be commited on exit of method1A().Right?



Scenarion2:-

Runtime exception occurs during method1B. Complete transaction will be rolled back.Right?


Scenarion3:-

Runtime exception occurs during method2A .Only transaction under method2A will be rolled back and rest of the transaction will be commited
on exit of method1.Right?



Scenarion4:-

Runtime exception occurs during method2B. Only transaction under method2B will be rolled back and rest of the transaction will be commited
on exit of method1.Right?

Posted at http://forum.springsource.org/showthread.php?113272-Understanding-Propagation-Required-and-Nested-scnearios&p=376001#post376001. But did not get replies as of now.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK lets do this another way.

A calls B
A might have started a transaction or it might not have. But B is set to be Transactional with a Propagation setting. What happens to A's transaction or lack there of, when B is called.




In both cases B will be running in a transaction. Either a new transaction in 3/4 scenarios or in 1 scenario just join A's transaction.

Also, in order to use NESTED, your Jdbc Driver must supports JDBC's save points. Otherwise NESTED will work exactly like REQUIRES_NEW

Mark
 
scott miles
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark For reply.Got your point. But it would be a great help if you can just reply the original post different scenario in yes/no to get the better clarity. sorry for inconvenience.Actually looking for it Long time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic