• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction attribute with EJB methods

 
Jim Janssens
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • 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...
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • 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
  • 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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic