1Z0-895 · Question #4
A developer implements a system in which transfers of goods are monitored. Each transfer needs a unique ID for tracking purposes. The unique ID is generated by an existing system which is also used…
The correct answer is D. 0.addTransferNOT_SUPPORTED. Step 2: Must start a new transaction. use REQUIRES_NEW Step 3: No need for this step: use Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. Step 4: Use Mandatory: Use the…
Question
Exhibit
Options
- A0.addTransferREQUIRED
- B0.addTransferREQUIRED
- C0.addTransferREQUIRED
- D0.addTransferNOT_SUPPORTED
How the community answered
(19 responses)- A5% (1)
- B16% (3)
- C5% (1)
- D74% (14)
Explanation
Step 2: Must start a new transaction. use REQUIRES_NEW Step 3: No need for this step: use Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. Step 4: Use Mandatory: Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client. *In an enterprise bean with container-managed transaction(CMT)demarcation, the EJB container sets the boundaries of the transactions. You can use container-managed transactions with any type of enterprise bean: session, or message-driven. Container-managed transactions simplify development because the enterprise bean code does not explicitly mark the transaction's boundaries. The code does not include statements that begin and end the transaction. *A transaction attribute can have one of the following values: *Required Attribute If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container starts a new transaction before running the method. The Required attribute is the implicit transaction attribute for all enterprise bean methods running with container-managed transaction demarcation. You typically do not set the Required attribute unless you need to override another transaction attribute. Because transaction attributes are declarative, you can easily change them later. *RequiresNew Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container takes the following steps: Suspends the client's transaction Starts a new transaction Delegates the call to the method Resumes the client's transaction after the method completes If the client is not associated with a transaction, the container starts a new transaction before running the method. You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction. *Mandatory Attribute If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container throws the TransactionRequiredException. Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client. *NotSupported Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container suspends the client's transaction before invoking the method. After the method has completed, the container resumes the client's transaction. If the client is not associated with a transaction, the container does not start a new transaction before running the method. Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. The Java EE 5 Tutorial,Container-Managed Transactions
Topics
Community Discussion
No community discussion yet for this question.
