Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

On transactions  RSS feed

 
Suresh Shanmugam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a stateless session bean
if one method starts transaction,can the other one close it?
Also, can anybody xplain the differences in transaction with various bean types??
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suresh
I am also on a learning road on J2EE but I would throw what I understand.
According to me, stateless session beans dont' store any state and so the each method call is different and independent of each other.
So your question that "whether one method can open a transaction and other can close it" doesn't fit to stateless session bean definition.
If you need that functionality, it means you have stateful bean in desing...
Regards
Maulin
 
sever oon
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. With EJBs, transactions are declaratively given attributes that define their scope. So if a particular method on an EJB is marked "Required", then that means if the method is called inside the context of an existing transaction, then it continues on in the context of that transaction. If it is called not in the context of a transaction, one is created and used for the scope of that call only.
Picture in your mind the callstack, starting with the JVM's call to main() (which is usually initiated by the app server for an EJB, meaning you don't write the main(), but that doesn't mean it's not there somewhere in the app server itself) all the way to your EJB method. Whenever a new transaction is started, it begins with that call being put on the call stack (the method is called) and ends when that call is removed from the call stack (the method returns).
sev
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sever,
When you say,

With EJBs, transactions are declaratively given attributes that define their scope.

You are referring to container managed transactions but it doesn't apply to Bean managed transaction scenario which I doubt Suresh is having...
If he has the CMT then your point is perfectly right.
Suresh, can you please give more details about what you have and what you want? As you already see the short post leads to assumptions...
Regards
Maulin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!