This content has been marked as final.
Show 4 replies
-
1. Re: contradiction between the Sun tutorial and JBoss-Wiki
starksm64 Jan 5, 2006 11:39 AM (in response to eitangur)Simple, EJBContext != UserTransaction.
-
2. Re: contradiction between the Sun tutorial and JBoss-Wiki
eitangur Jan 8, 2006 2:03 AM (in response to eitangur)From the J2EE API:
setRollbackOnly
public void setRollbackOnly()
throws IllegalStateException
Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method.
Throws:
IllegalStateException - The Container throws the exception if the instance is not allowed to use this method (i.e. the instance is of a bean with bean-managed transactions).
I'm a little confused - aren't we getting the user transaction from the SessionContext in the SessionBean? Are you saying that:sessionContext.setRollbackOnly();
is different fromUserTransaction ut = sessionContext.getUserTransaction(); ut.setRollbackOnly();
?
If so - in what way?
Thank you very much. -
3. Re: contradiction between the Sun tutorial and JBoss-Wiki
hitcher Apr 10, 2006 10:11 AM (in response to eitangur)well, a UserTransaction is a different object than the sessioncontext.
You can use a UserTransaction in an application outside of your EJBs (e.g. a web application) to execute several remote calls to your EJBs within one transaction context. -
4. Re: contradiction between the Sun tutorial and JBoss-Wiki
hitcher Apr 10, 2006 11:26 AM (in response to eitangur)My last post is not quite complete.
UserTransactions are of course also use in Beans with BMT. However, the UserTransaction object is the object that you have to use to start, commit and rollback your transactions. The EJBContext holds the state for an EJB (CMT and BMT) and is managed by the AppServer, which is why you should not call setRollback on the context.