Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Transaction Questions

 
Steven Wong
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

1. Can I create any new transactions in between existing transactions in CMT or BMT?

2. If I initiate a User Transaction in my servlet to call Session Beans (which in turn contain its own transactions), can they rollback or this is not allowed by the EJB Container?

3. Inside the bean, all the methods have to have either Container OR Bean but not both, am I right?

Thanks.
 
Marcelo Sousa Ancelmo
Ranch Hand
Posts: 498
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steven Wong:
Hi,

1. Can I create any new transactions in between existing transactions in CMT or BMT?

You cannot create nested transactions.

2. If I initiate a User Transaction in my servlet to call Session Beans (which in turn contain its own transactions), can they rollback or this is not allowed by the EJB Container?
The UserTransaction is the one provided by the container? Then if you roolback the transaction in the bean, all the participant transactions will roolback (not 100% sure about this one)


3. Inside the bean, all the methods have to have either Container OR Bean but not both, am I right?
Are you talking about transaction configuration? You are right, but you configure the Bean as CMT or BMT


Thanks.


You are welcome

Regards,
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Can I create any new transactions in between existing transactions in CMT or BMT?

About this, I have a little different idea.

Let's suppose the following situation:
1)a BMT bean calls a method, say f1() of a CMT bean.
2)the BMT bean's transaction attribute is configured requirednew
3)in f1(), javax.transaction.UserTransaction.begin() is called

I think the code could run without any problem:
The f1() is invoked with a transaction context and in turn it initiate a new transaction.

if the f1() method of the CMT bean is replaced by a requirednew method of a BMT bean, the situation is the same. a brand new transaction would be initiated.

While if javax.transaction.UserTransaction.begin() is called twice in the f1(), an exception would be thrown.

As for nested transactions, what does it exactly mean? Could anyone shed much lights on this?

Regards,
James
[ February 27, 2005: Message edited by: James Du ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic