"An instance that starts a transaction must complete the transaction before it starts a new transaction."

"A stateful session bean instance may, but is not required to, commit a started transaction before a business
method returns. If a transaction has not been completed by the end of a business method, the container
retains the association between the transaction and the instance across multiple client calls until
the instance eventually completes the transaction."

Read on page no 343 of core-specification. It says

"When an instance attempts to start a transaction using the begin method of the javax.transaction.
UserTransaction interface while the instance has not committed the previous transaction,
the container must throw the javax.transaction.NotSupportedException in the begin
method."

Cheers,<br />Chandrashekhar <br />SCJP

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845

posted Feb 16, 2009 16:42:33

0

Please read it carefully-

Answer says-

2) The bean instance that starts a transaction must complete the transaction before it starts a new transaction.

And specification says-

A stateful session bean instance may, but is not required to, commit a started transaction before a business
method returns.

Chandrashekhar Raiphale
Greenhorn

Joined: Aug 26, 2006
Posts: 14

posted Feb 16, 2009 20:13:23

0

yes, that is alos correct.

see "Table 12 Container’s Actions for Methods of Beans with Bean-Managed Transaction".

If the transaction associated with the instance is T1, then business called will be execuated in same transaction.

"A stateful session bean instance may, but is NOT REQUIRED to, commit a started transaction before a business method returns. If a transaction has not been completed by the end of a business method, the container retains the association between the transaction and the instance across multiple client calls until the instance eventually completes the transaction. "

Amandeep Singh wrote:i think this should also be fixed. Please verify.

Hello, As mentioned by Chandrashekhar, a bean is not allowed to start a new transaction before the existing transaction ends (the existing transaction may end in the same method call or it may span accross multiple method calls in case of SFSBs). So the given answer is correct and does not need any fix