For CMP entity beans, only the Required, RequiresNew, or Mandatory transaction attributes should be used for the transactional methods defined in the bean's component and home interface.
I am not really sure why this is so, I mean what is wrong with using NotSupported, Supports or Never? If I have my own business methods in an entity bean that I don't want to be in a transaction how could I do this?
Granted, with an entity bean mapped to a persistent store, I would most likely need to execute inside a transaction, but what if I didn't?
Anyone who had any ideas about this please help!
James. [ November 09, 2004: Message edited by: James Turner ]
The reason you cannot use the other three transaction attributes viz., Supports, Not Supported and Never is because entity beans are always transactional i.e. they have a meaningful transaction context. The other three transaction attributes allow (or enforce) the entity bean's method to run under an unspecified transaction context.
The reason why entity beans are always transactional is because they model shared, persistent business data (and methods that act on the business data). Since they (as in-memory objects) represent persistent data, they need to synchronize themselves with a persistent data store through calls to ejbLoad() and ejbStore(). The use of the ejbLoad and ejbStore methods for caching an entity object�s state (which is what an entity bean does) in the instance works well only if the Container can use transaction boundaries to drive the ejbLoad and ejbStore methods. When one of the three attributes specified above is assigned to a remote interface or a home business method, the corresponding enterprise bean class method executes with an unspecified transaction context. This means that the Container does not have any well-defined transaction boundaries to drive the ejbLoad and ejbStore methods on the instance.
Therefore, the ejbLoad and ejbStore methods become unreliable under the above scenario. This would result in a condition where the entity bean's in-memory state does not match the persistent data state which is highly undesirable.