Three things:

1) You should only have one DAO manager, even with multiple databases.

2) In my opinion, your transactions should be at the service level.  Make more coarse grained service methods that demarcate transactional scope. 

3) Be very careful with multiple start/commit/end blocks.  You should consider a global transaction manager if you're working with multiple databases.

Cheers,
Clinton


On 8/4/05, Darek Dober <[EMAIL PROTECTED]> wrote:
Hi

I use petstore as example so I have:

affairService and debtorService which gives me method like
updateAffair(Domain affair) and updateDebtor(Domain debtor)

Now I want them to be executed in one transaction

I try to do something like this

update() {
...
try {
affairService.getDaoManager().startTransaction();

affairService.updateAffair(affair);
debtorService.updateDebtor(debtor);

affairService.getDaoManager ().commitTransaction();

} catch (Exception ex) {
..
} finally {
affairService.getDaoManager().endTransaction();
}

But after that operation i have some locks in database.

Is this the correct way, or should I use start/commit/endTransaction()
method at the lower level of  ...sqlMapDao (i.e affairSqlMapDao)
Or maybe I should do it in pairs like:
affairService.getDaoManager().startTransaction();
debtorService.getDaoManager().startTransaction();

..
affairService.getDaoManager().commitTransaction();
debtorService.getDaoManager().commitTransaction();


Darek Dober


Reply via email to