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"?
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...
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
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?