• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transaction attribute with EJB methods

 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a bit confused about this, the specs says (17.4.1) :

The transaction attribute must be specified for the following methods:

- Session: methods in the component interface and super interfaces
- Entity: methods in component/home interface and super interfaces + remove methods in EJB(local)Object/EJB(local)Home interfaces
- Message driven: onMessage

Now, how do I see this 'MUST' context ? Do these methods NEED to have a transaction context ? ...

For example; I can create an CMT session bean and do not specify the 'container-transaction' element at all in the deployment descriptor. The same for an entity bean...
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not get confused by some Containers which allow you not to specify transaction attributes (because they will use default values). If the EJB spec says "must", then it is mandatory. The spec is the supreme authority as far as the exam is concerned.
 
Jim Janssens
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, but, can you confirm that for a bean (take a SSB for example) you *MUST* specify a transaction attribute in the assembly descriptor for every method in the component interface ?

Assume the component interface of that SSB with the following method:

"public int returnCurrentTime() throws RemoteException;"

In order for this to be a legal SSB, I must declare the following assmembly descriptor:

<assembly-descriptor>
<container-transaction>
<trans-attribute>some trans attrib here</trans-attribute>
<method>returnCurrentTime</method>
</container-transaction>
</assembly-descriptor>

If I do not specify this it is not valid then ?

I find it a bit hard to accept since it is the first thing I hear about this. I always thought that when you do not want a method to use transaction you simply do not specify the methods in the container-transaction of the assembly descriptor..
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic