• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in JavaBeat question

 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Following is the question from Javabeat:

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.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option A enforces Transaction but option B does not.
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to clarify.

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).
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


Here the keyword is within. A method with REQUIRED transaction context can be called even when its not within. a transaction context but for MANDATORY, its requred to be called within a transaction.

I guess this question is a bit ambiguous and has to do more with grammar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic