Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF exam Question on Transacton

 
kishore chitturi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to EJB. Can any body help me?
If a session beans business method invokes, EJBContext.setRollBackOnly(),which transaction attribute settings can cause the container to throw the java.lang.IllegalStateException?

1. NotSupported
2. Required
3. Supports
4. RequireNew
5. Mandatory
6. Never.


Answers are NotSupported, Supports and Never.

Can any body help why these are the answers only?
 
jojo agarwal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Container can Rollback only when business method is in transaction, but when transaction does not exist and trying to Rollback. It will always give java.lang.IllegalStateException.
Because NotSupported , Supports, Never only these three transaction attribute allows a method call without existing a transaction.
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods like setRollbackOnly or getRollbackOnly throw IllegalStateException if there is no Transaction Context. Supports, NotSoppurted and Never transaction attributes means there is not (or might not - for supports) a Transaction Context.

Generally method which should be called in a transaction context throw IllegalStateException when called from a method not executing in a transaction. This is the ground for the answers given

Regards,
Leena
[ March 11, 2005: Message edited by: Leena Diwan ]
 
kishore chitturi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank You for giving reply
regards
kishore
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic