About Question enthuware.oce-ejbd.v6.2.489 :
Moderator: admin
About Question enthuware.oce-ejbd.v6.2.489 :
Isn't setRollbackOnly() only for CMT? But the code in the question apparently is BMT.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
No, UserTransaction's setRollbackOnly() is used by BMT beans.
EJBContext's setRollbackOnly() is used by CMT beans.
HTH,
Paul.
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.
-
- Posts: 10
- Joined: Thu Aug 09, 2012 1:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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.
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.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
This should help : RollbackException.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.
HTH,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.
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Wed Jul 02, 2014 2:00 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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?
Based on the above discussion, isn't the transaction management type a BMT?
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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.
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.
-
- Posts: 3
- Joined: Tue Mar 22, 2016 6:25 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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?
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?
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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.
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.
-
- Posts: 16
- Joined: Tue Nov 08, 2016 9:39 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
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
¿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
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.489 :
1. No, it can appear only in a bean with BMT.
2. No.
2. No.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 101 guests