ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darek Dober" <doover...@op.pl>
Subject Re: daoManager start/end/commit transaction problem - solved:)
Date Fri, 05 Aug 2005 09:14:08 GMT
Thanks for your answer,I solved the problem
It is difficult to say, but It was very obvious fault:)


By the way I have one dao manager.

Problem was that, I had my code different, than I wrote in my post.

I didn't excecute endTransaction() (It was in my catch exception section instead of finally
section), so after commitTransaction, transaction was still in progress.

I was tricked by the fact, that commit transaction should release all resources and locks.
Database transaction was commited, but still locked the tables

Can you explain that magic. I always thought, that commit releases resources?

Anyway thanks for help

Best regards
Darek Dober

----- Original Message ----- 
  From: Clinton Begin 
  To: user-java@ibatis.apache.org 
  Sent: Friday, August 05, 2005 1:09 AM
  Subject: Re: daoManager start/end/commit transaction problem



  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 <dooverone@op.pl> 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




Mime
View raw message