• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

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..
 
I do some of my very best work in water. Like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic