This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Which of the following transaction attribute instructs the Container that the business method defined within an enterprise bean should be executed within an active transaction? a. MANDATORY b. REQUIRED c. NEVER d. None of the above.
The correct Answer is:a But my answer is a&b Please explain whether I am correct or not.
When the transaction attribute is MANDATORY, the business method needs to be called with an existing transaction context, e.g. it cannot be called with an unspecified transaction context (aka no transaction context).
When the transaction attribute is REQUIRED, the business method may be called with no transaction context or with an existing transaction context. In the first case (no transaction context), the Container will create a new transaction for the method to run in. In the second one, it will use the client's transaction (by client I mean a client to the bean's business method; it can be a real client application or another bean).
The above question is not for the client. It is for the Bean's business method. Which attributes tell the container that the business method should be executed in a transaction context? 1)MANDATORY-> Obvious. Name itself is telling that. 2)REQUIRED-> Name itself is telling that Transaction context is REQUIRED for the Method. So, the Answer should be above two. Please let me where I am going wrong.