Valid 1Z0-895 Dumps shared by ExamDiscuss.com for Helping Passing 1Z0-895 Exam! ExamDiscuss.com now offer the newest 1Z0-895 exam dumps, the ExamDiscuss.com 1Z0-895 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com 1Z0-895 dumps with Test Engine here:
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 by other applications. For performance reasons, the transaction that gets the unique ID should be as short as possible. The scenario is implemented in four steps which are implemented in four business methods in a CMT session bean: These methods are called by the addTransfer method of a second CMT session bean in the following order: checkGooods, getUniqueId, checkAmount, storeTranfer Assuming no other transaction-related metadata, which is the correct set of transaction attributes for the methods in the session beans?
Correct Answer: A
Explanation/Reference: Step 2: Must start a new transaction. use REQUIRES_NEW Step 3: No need for this step: use Not Supported Use the NotSupportedattribute 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. Note: * 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 RequiresNew Mandatory NotSupported Supports Never * 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. Reference: The Java EE 5 Tutorial, Container-Managed Transactions