Hello,
We had initiated this discussion a few days ago. I am looking for some
comments on my implementation of this pattern. Here is the description
1) I have a Session bean (as Session Facade) which has a method to open a
new account (lets call it sf_method1 representing method1 of session
facade). Opening a new account requires us to insert the account information
in the database and to link this account to a customer.
1.1) The method in Session Facade (sf_method1) calls sb_acct_method1
(method1 of account session bean). This method will insert the account
information in the database. To insert this data it makes use of a data
access object. Say it calls the method dao_method1 where dao_method1 will
insert the data (account information) in the accounts table.
1.1.1) dao_method1 obtains a connection from the connection pool by looking
up for the data source object (javax.sql.DataSource). It then inserts the
account information in account_info table
1.2) The next method called by session facade bean is sb_acct_method2
(method2 of the same session bean as in step 1.1) . This method inserts a
records in Customer_Account table. This table merely contains two columns -
Customer_Id and Account_Id. Even this method uses the abovementioned DAO to
insert the data in Customer_Account table. Say it calls dao_method2.
1.2.1) dao_method2 obtains a connection from the pool and inserts the data
in Customer_Account table.
The question is whether and how do I use declarative transactions?
I have declared the attribute of sf_method1 as REQUIRESNEW and that of
sb_acct_method1 and sb_acct_method2 as REQUIRED.
In the dao_method2 I have a division by zero exception. When I run the
client, the data is inserted in the account_info table (whereas I did not
expect it because the second part of the transaction namely inserting into
Customer_Account table) failed .
What I could derive from this is
1) The transactional scope of a method (of a bean) does not extend to Java
classes that it might be calling.
2) By using DAO patterns, the transaction management becomes the
responsibility of the programmer.
Please let me know if I have got it wrong.
I was also wondering about the usability of this pattern in areas where we
have only session beans. This ofcourse goes with the assumption that we
cannot extend transactional scope of a bean to the Data Access Objects. Does
merely seperating the data access logic justify the cost of managing
transactions?
Thanx a lot in anticipation
Jeetendra Dassani
Lead Systems Engineer
Tata Infotech Limited
SEEPZ, Andheri (E)
Mumbai.
Email : [EMAIL PROTECTED]
[EMAIL PROTECTED]
Telephone: 8291261 X 2775/2465
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".