• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

EJB Transaction Questions

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 498
Eclipse IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic