Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Transactions  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have two questions regarding transactions:

1. When inplementing SessionSynchronization for Sesion Beans, the callback method "beforeCompletion()" is said to run before the end of the transaction -after the business method end- OK.
It is said that in that method you can update the database before end of transaction, but how could I know whether the transaction will commit or rollbact while this methods runs before the end of transaction?
In other words, if I updated the DB and then the transaction rollback then how could I return the old value of the db?

2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?
more clarification needed for why the other attributes are not needed.

Thank you in advance
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Emad Al-Agouz:


1. When inplementing SessionSynchronization for Sesion Beans, the callback method "beforeCompletion()" is said to run before the end of the transaction -after the business method end- OK.

2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?



1. Yea, beforeCompletion () will be invoked by the container before the completion of the transaction. That means before either transaction rollback or transaction commit.

I think that, in this method you can do all finalization operation depends up on the status of the transaction. You can get the status of the transaction from userTransaction.getStatus() in BMT and You can use EJBContext.getRollbackOnly() in the case of CMT.


2. MDB have no client view, so rest of the transaction attributes are not meaningful.
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Emad Al-Agouz:
2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?
more clarification needed for why the other attributes are not needed.



For MDBs the possible cases are only these two - Either they execute in a transaction context or it is not supported.

RequiresNew, Mandatory, Never, Supports transaction attributes have behaviours which are dependent on if the client is using any existing transaction. Which is not possible for MDBs.

Regards,
Leena
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. Yea, beforeCompletion () will be invoked by the container before the completion of the transaction. That means before either transaction rollback or transaction commit.



If txn is going to rollback beforeCompletion() wont b called by the container. onli calls this methd if the txn is going to commit.

thanx binoj
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ....

beforeCompletion is for stateful session with CMT only.....so u cannot use UserTransaction here.
This place is your last change to rollback the tx if you want to. So, if you think this tx is not good enough to be allowed to commit, you can do it here.
So I think its much use is going to be for rolllbacking last chance.


but container doesnt calll it if Tx is going to be rollbacked. So its much useful if you want to apply some logic and put Tx to rollback........your last chance as a B P.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!