This week's book giveaway is in the Android forum.
We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line!
See this thread for details.
Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Beans CMT BMT  RSS feed

 
AR Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

just a quick question. On HFEJB pg 196 it tells us that:

(for STATEFUL Session Beans)

You CAN'T:
- force a trans to rollback (CMT beans)
- find out if trans already set to rollback (CMT beans)

But you CAN:
- get a trans ref and call meths on it (BMT beans)

I'm just wondering why you can access the BMT transaction but not the CMT transaction.

Many thanks
AR Shah - SCJP - SCWCD
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a session bean, only the methods in the component interface are transactional, you need to mark them with a transaction attribute if you are using CMT. The home interface methods like create are non-transactional. Hence the container would run them in an Unspecified Transaction Context. The rule is that if a method runs in an Unspecified Transaction Context, then you cannot call context.setRollbackOnly() and context.getRollbackOnly() i.e. ask the container to rollback the transaction or check to see if it is rolled back. Doing so will throw an IllegalStateException. But if you are using BMT, you are free to get the UserTransaction reference and start your own transaction. This will be clearer after you read the transactions chapter.
 
AR Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - that makes perfect sense!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!