• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion related to @Transactional annotation

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hi Great Ranchers,


Please refer the below code.






In class shown above insertUser() makes a call to deleteUser(). As per my understanding deleteUser() should have been executed in a new/saparate transaction, as it's annotated as @Transactional(propagation = Propagation.REQUIRES_NEW), but it's not happening that way. Instead deleteUser() is also executing in same transaction as that of insertUser(). Below is the log for this code which shows the same.



If that's correct than what is the use of @Transactional(propagation = Propagation.REQUIRES_NEW) annotation at deleteUser().

How a method will execute in saparate transaction if it's marked with an annotation @Transactional(propagation = Propagation.REQUIRES_NEW).

I am confused, please help me. Please let me know if question is not clear.


Best Regards,
Maneesh Saxena
 
Maneeesh Saxena
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
complete log in case it's needed.

 
Maneeesh Saxena
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any One .. Any Help !!!
 
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
Transactions are added via a Proxy. But if one method inside your dao calls another method inside your dao. The call does not go back outside the class to call through the proxy again. So therefore, the second method is called directly from the first method and no Transaction code will be wrapped around the second method.

So imagine you go into a house, and at the door you get something handed to you. You are in the hallway now and you go to the kitchen. To get to the kitchen, you don't go through the front door again, you go directly to the kitchen.

Mark
 
Maneeesh Saxena
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mr. Mark. I got it. Thanks for such a nice explanation.

Best Regards,
Maneesh Saxena
 
Mark Spritzler
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

Maneeesh Saxena wrote:Thanks Mr. Mark. I got it. Thanks for such a nice explanation.

Best Regards,
Maneesh Saxena



Thank you. I made up that analogy on the fly as I was typing. But I really do like it.

Mark
 
"To do good, you actually have to do something." -- Yvon Chouinard
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic