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

Moderator: admin

Post Reply
kezman9
Posts: 26
Joined: Fri Jul 06, 2012 1:08 am
Contact:

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

Post 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

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

kezman9
Posts: 26
Joined: Fri Jul 06, 2012 1:08 am
Contact:

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

Post by kezman9 »

Now it's clear, thank you.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests