DAO and transactions
843854Jan 20 2004 — edited Nov 22 2006
Scenario:
I have defined one of my DAO functions as follows:
public interface IEmployee
{
// creates a new employee entry
public int create(EmployeeInfo info) throws DataAccessException;
}
create() inserts information in THREE different tables.
My opinion:
Since THREE rows are being updated, there needs to be transaction around the create() function. I am
of the opinion that transactions should be managed by the business layer and not in the DAO layer.
Question:
1. Is my understanding of DAO layer correct i.e. transactions should not be managed in the DAO layer?
2. If the answer to the previous question is YES, then should comments in the function header be sufficient to indicate to the business layer user that he needs to wrap the call to CREATE() in a transaction block??
Thanks
Jawahar