Search your topic in Java2share
Home > SCBCD > SCBCD Question Bank
eXTReMe Tracker


9. Transactions (SCBCD)

Q: 01 A CMT session bean named MrBean is annotated as follows :
21. @Stateless(name="MrBean")
22. @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
23. public class MrBean {
24. public void storeStuff() {}
25. There are no transaction annotations at the method level.
Given the following snippet of an ejb-jar.xml:
23. <container-transaction>
24. <method>
25. <ejb-name>MrBean</ejb-name>
26. <method-name>storeStuff</method-name>
27. </method>
28. <transaction-attribute>Mandatory</transaction-attribute
29. </container-transaction>
Which statement is correct about the business methods in MrBean?

A. All methods have transaction attribute REQUIRED.
B. All methods have transaction attribute MANDATORY.
C. All methods have transaction attribute NOT_SUPPORTED.
D. Methods with name storeStuff have transaction attribute MANDATORY and all other methods have
transaction attribute REQUIRED.
E. Methods with name storeStuff have transaction attribute MANDATORY and all other methods have
transaction attribute NOT_SUPPORTED.
F. Methods with name storeStuff have a transaction attribute REQUIRED and all other methods have
transaction attribute NOT_SUPPORTED.

Answer: E

Q: 02 A developer wants to achieve the following two behaviors for an EJB 3.0
session bean:
(1) If the client calls a business method with a transaction context, the container will invoke the enterprise
bean's method in the client's transaction context.
(2) If the client calls a business method without a transaction context, the container will throw the
javax.ejb.EJBTransactionRequiredException.
Which transaction attribute should be used?

A. REQUIRED
B. SUPPORTS
C. MANDATORY
D. REQUIRES_NEW
E. NOT_SUPPORTED

Answer: C

Q: 03 Given a stateless session bean with container-managed transaction
demarcation, from which two methods can a developer access another enterprise bean? (Choose two.)

A. bean constructor
B. Timeout callback method
C. PreDestroy lifecycle callback method
D. PostConstruct lifecycle callback method
E. business method from the business interface

Answer: B, E

 

Q: 04 A session bean calls the setRollbackOnly method on the EJBContext interface
within a business method with an active transaction. Which two are correct? (Choose two.)


A. The transaction timeout is immediately disabled.
B. The container will ensure that the transaction will never commit.
C. The bean must have started the current transaction for this to be legal.
D. The bean must have bean-managed transaction demarcation for this to be legal.
E. The bean must have container-managed transaction demarcation for this to be legal.

Answer: B, E