This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do we need specify transaction attribute for ejbRemove of Entity Bean

 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On P498, for Entity bean, we have to specify the transaction attribute for those business methods, removes from both interfaces, create () etc.
My question is "should we specify transaction attribute for ejbRemove, ejbCreate () etc, or the Container will take care of these ejbMethod"?

thanks
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section 17.4.1 of the spec enumerates all methods for which transaction attribtues must or must not be specified:


The transaction attribute must be specified for the following methods:
[...]
For an entity bean, the transaction attributes must be specified for the methods defined in the bean�s component interface and all the direct and indirect superinterfaces of the component interface, excluding the getEJBHome, getEJBLocalHome, getHandle, getPrimaryKey, and isIdentical methods; and for the methods defined in the bean�s home interface and all the direct and indirect superinterfaces of the home interface, excluding the
getEJBMetaData and getHomeHandle methods specific to the remote home interface.
[...]


As you can see, there is no mention of the ejbMethods... If you come to think about it, this is pretty normal as the ejbMethods are called by the container as a result of a client interaction. For instance, when the client invokes create() on the home interface, ejbCreate will be called on the bean class and the transaction context will be propagated so there is no need to specify the transaction attributes for both create() and ejbCreate(). The same goes for the other methods...

Does this make sense to you?
 
Jingyi Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But for entity bean, we do have to specify some Transaction Attribute for create method since this method will involve in database insert, right?
Anyway, your explanation does make sense to me.
Thanks a lot
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But for entity bean, we do have to specify some Transaction Attribute for create method since this method will involve in database insert, right?
What you do is actually to specify a transaction attribute for the home interface of the entity bean and not for the entity bean itself. See the difference?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic