Page 1 of 1

About Question enthuware.oce-ejbd.v6.2.607 :

Posted: Wed Jul 31, 2013 4:43 am
by kezman9
Hi,

Fourth answer says
A bean can call this method only if it has started the transaction.
Should I implicitly assume that this answer references to BMT and that's why it is incorrect?

As of spec 4.7.2 (for stateless session beans but it is the same for other types)
The getRollbackOnly and setRollbackOnly methods of the SessionContext interface should be used only in the session bean methods that execute in the context of a transaction. The container must throw the java.lang.IllegalStateException if the methods are invoked while the instance is not associated with a transaction.
it looks like it is correct answer and it could be incorrect in case I mentioned earlier.

Thanks,
Jarek

Re: About Question enthuware.oce-ejbd.v6.2.607 :

Posted: Wed Jul 31, 2013 11:05 am
by admin
It is incorrect because it says "only if the bean has started the transaction", while the requirement is that the bean should be in a transaction. Whether it started the transaction is immaterial.

For example, for a stateful bean, a bean may not have started the transaction.

It could be deemed incorrect for the reason you mentioned as well.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.607 :

Posted: Wed Jul 31, 2013 11:50 am
by kezman9
Now it's clear, thank you.

Re: About Question enthuware.oce-ejbd.v6.2.607 :

Posted: Sun Jun 07, 2015 2:46 pm
by himaiMinh
For option 2
Once called, the container ensures that the transaction will never commit.
I think that is only true if there is a transaction running. If there is no transaction running (for example, transaction attribute = NOT_SUPPORTED or NEVER), calling EJBContext.setRollbackOnly() will give an IllegalStateException.