• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Wrong Enthuware Answer

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following are true regarding a bean with bean managed transaction demarcation?

1) The bean must be a session bean or a message-driven bean.

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

3) The bean may use nested transactions.

4) If it is a a stateless session bean, it must commit a transaction before a business method or timeout callback method returns.

5) If it is a message-driven bean, it must commit a transaction (if it exists) before its message listener method returns.

Explanation- This is not fully true. A message driven bean may commit the transaction even in a timeout callback method.

the correct answer is 1,2 and 4.

the 2nd answer is absolutely wrong, because that statement is not fully true. SFSB's may not commit a trsansaction before they start a new transaction.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Please read on page no 325 of core-specification. It says

"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."
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

There will not be new transaction, if you tried to create one, you will get javax.transaction.NotSupportedException in the begin
method.



following lines from MK's study guide

"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
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think this should also be fixed. Please verify.
 
Enthuware Software Support
Posts: 4897
60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic