Page 1 of 1

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

Posted: Fri Oct 05, 2012 8:15 pm
by ETS User
Isn't setRollbackOnly() only for CMT? But the code in the question apparently is BMT.

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

Posted: Sat Oct 06, 2012 4:30 pm
by admin
No, UserTransaction's setRollbackOnly() is used by BMT beans.

EJBContext's setRollbackOnly() is used by CMT beans.

HTH,
Paul.

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

Posted: Fri Oct 12, 2012 8:08 pm
by Misha
In the explantation:
Calling UserTransaction.commit() when a transaction has been set for rollback only, will throw a javax.transaction.RollBackException.

I couldn't find RollBackException in the specs.

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

Posted: Sat Oct 13, 2012 5:09 pm
by admin
Misha wrote:In the explantation:
Calling UserTransaction.commit() when a transaction has been set for rollback only, will throw a javax.transaction.RollBackException.

I couldn't find RollBackException in the specs.
This should help : RollbackException.
RollbackException exception is thrown when the transaction has been marked for rollback only or the transaction has been rolled back instead of committed. This is a local exception thrown by methods in the UserTransaction, Transaction, and TransactionManager interfaces.
HTH,
Paul.

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

Posted: Tue Aug 12, 2014 1:04 am
by amaebi
Can someone help to explain why 2nd last option "The bean must be an EJB 3.x entity with bean managed persistence." is a valid answer?

Based on the above discussion, isn't the transaction management type a BMT?

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

Posted: Tue Aug 12, 2014 2:44 am
by admin
Because the bean might be a MDB as well (option 1). While this option (6) says "must".

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

Posted: Mon Jun 15, 2015 3:04 pm
by himaiMinh
In the API about UserTransaction.commit() at
http://docs.oracle.com/javaee/6/api/jav ... mmit%28%29
It says "RollbackException - thrown to indicate that the transaction has been rolled back rather committed."

So, the commit method will throw RollbackException only if the transaction has already been rolled back. But in this case, the transaction, ut, is marked for rollback, not rolled back yet.
According to this API, commit() should not throw RollBackException.

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

Posted: Wed May 11, 2016 5:19 am
by pentavalle
I'm not sure to understand why "Upon execution of this code, the container ensures that the transaction is not committed." is correct.
In BMT transaction context is always new, there's no propagation of the caller context, so usertransaction is new and can't be committed yet.
Could it be related to the fact that in a stateful session bean the usertransaction could be leaved open for the entire conversation scope and this method retrieves a transaction opened in a previous call?

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

Posted: Tue May 17, 2016 9:58 pm
by admin
Sorry for replying late.
It is talking about the transaction referred to in the code. ( ut.begin(); ) This transaction will not be committed.

HTH,
Paul.

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

Posted: Sun Dec 25, 2016 8:51 pm
by Gerardo
Hi, I have the following doubt:

¿Can the "code" appear inside an EJB with CMT and BMT?
¿Is it allowed to use ut.begin() and ut.commit() inside an EJB with CMT?

Many thanks in advance

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

Posted: Mon Dec 26, 2016 12:33 am
by admin
1. No, it can appear only in a bean with BMT.
2. No.