- Posted by: Paddy Murphy
- Posted on: February 19 2004 13:54 EST
I am using bean managed transactions, using JTA. My code requires to access two entity beans, modify the attributes, and then commit all changes. I am using JTA demarcation, looking up JNDI first, and then begining the transaction, modifying the beans, and finally committing. However, I am unsure as to whether the lookup of the entity bean remote interfaces (i.e. the finder method calls) should be within the JTA transaction ut.begin and ut.commit statements or not.
1) when using declarative transactions, is it normal to give the ejbfinder method a transactional attribute (i.e. one of Required, Mandatory, Never, Supports, RequiresNew, NotSupport)? Which one is normally used?
2) For bean managed transactions, should the finder methods be part of the JTA transaction or seperate, and why?
- Should finder methods be included in JTA transaction context? by Paul Strack on February 20 2004 19:55 EST
It depends on your situation. In particular, does your transaction require that the data your read not be changed during the scope of the transaction.
Most people advocate a "default" transactional attribute of "Required". I sometimes advocate using "Supported" for read-only operations (including finders) because you can sometimes get improved performance by avoiding the transaction overhead.
If you are managing the transaction yourself (BMT), you have to decide the requirements of your transaction on your own.