Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Doubt in JavaBeat question

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option A enforces Transaction but option B does not.
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic