Win a copy of Pipeline as Code this week in the Cloud/Virtualization 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Knowing about the transaction

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a small doubt regarding the transaction.
Following is the code:

Lets say I am calling a method from a method which involves with the transaction.
Now, Can I know by any chance that I am with in a transaction from the method calculateUserCount()??
If the calculateUserCount() is another Bean method what would be the case?
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, you can be sure that there is a transaction.
No transaction attribute is specified on the class or on the calculateUserCount().
The default transaction attribute is REQUIRED.
In other words there will always be a transaction when the method is called.

Usually you would use transaction attributes to answer the question you asked.
It makes little sense to use an attribute of SUPPORTS
and then poll the transaction, because you actually need one.
I you want to ensure that the method is always called within an existing transaction, then assign an attribute of MANDATORY.

Since the bean is stateful you can use the SessionSynchronization interface as well.
This way you can monitor the transaction status.
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic