Database updates in EJB

Hi,

Can anyone help me out ?

I am using Stateless session bean. In my bean, I call BO class which performs business validations and then , call Data Access Object class

(say, class A) .The class , A updates database table A, then, calls Data Access Object class B which updates database table B and class A then calls Data Access Object C which updates tables C.All the above are performed in the same DAO class A's method.

TheEJB method transaction attribute has been set to Required.

My question is can I pass the same connection from class A to class B and C. Or,is it good to use separate connections (fetched from the connection pool) in class A,B and C ?

I know both ways will work. Can someone say me which will be fatser and better than the other.

Thanks in advance.

[824 byte] By [tmmeta] at [2007-11-27 4:12:23]
# 1

Obviously, if you use the same connection it will be faster as the Transactionmanager doesn't have to do a 2PC (2 phase commit protocol) to commit the Tx.

In sun appserver, even if ClassA, ClassB and ClassC call getConnextion() they get the same connection (since they execute in the same Tx) and hence work correctly (and optimally).

Mahesh.Kannana at 2007-7-12 9:18:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...