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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

Isn't setRollbackOnly() only for CMT? But the code in the question apparently is BMT.

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

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

Post by admin »

No, UserTransaction's setRollbackOnly() is used by BMT beans.

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

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Misha
Posts: 10
Joined: Thu Aug 09, 2012 1:32 am
Contact:

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

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

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

amaebi
Posts: 4
Joined: Wed Jul 02, 2014 2:00 am
Contact:

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

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

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

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

Post by admin »

Because the bean might be a MDB as well (option 1). While this option (6) says "must".
If you like our products and services, please help us by posting your review here.

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

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

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

pentavalle
Posts: 3
Joined: Tue Mar 22, 2016 6:25 am
Contact:

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

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

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

Gerardo
Posts: 16
Joined: Tue Nov 08, 2016 9:39 pm
Contact:

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

Post 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

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

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

Post by admin »

1. No, it can appear only in a bean with BMT.
2. No.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests