Do you mean when would you use Container Managed Transactions/CMT(method level) or Bean Managed Transactions/BMT (bean level)? Typically you will want to use CMT whenever you can, as it allows a cleaner separation between transaction control and business logics; the bean developer only focuses on business logics and you leave transaction details to the container (grab any EJB book, they'll give you a much better comparison) However, as live itself, everything comes to a cost, and the benefit of CMT introduces a 'small' performance problem on where you may end up locking database resources for longer than necessary. Sometimes this 'small' overhead is a problem. You may want to have a look at BMT. Going back to your question, you would use BMT, for example, when you have a large method doing time consuming processing, and only a small part of it performs database access requiring transactional isolation. In that case, assuming that performance is an issue, you may not want to have a 'method transaction', but to just start and commit the transaction to wrap your database code only.
... however, if you meant something else by 'method transaction' or 'bean transaction', then the answer would be I don't know... Eduard
I think he is talking about the level of granularity in declaring transaction attributes. Transaction attributes can be assigned to all methods in an EJB (what Kent refers to as "bean-level") or can be assigned to individual methods (what Kent refers to as "method-level"). Obviously, you use "bean-level" granularity when all the methods in an EJB have the same transactioning requirements. Use "method-level" granularity when methods have different transactioning requirements. Actually, you could use both. Define a "bean-level" transaction setting and override the setting on any methods with different requirements using "method-level" syntax.
Hi, I am talking about the granularity in declaring transaction attributes. It is quite obvious when to define transaction attributes on the entire bean, but I don't understand very well when would I want to define it for each method (maybe some of the methods). I am digest Chris's answer. Thanks,