ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Atomic transaction in iBATIS
Date Mon, 06 Mar 2006 19:38:39 GMT
In iBATIS, each call is a seperate transaction unless you override it.  You
can override with your own transaction management (DAO or SqlMap API calls),
or use an external transaction manager.

The method you mention above (AccountService.insertAccount()) will result in
three seperate transactions unless there is an external transaction
manager.  This is why it is a pretty good practice to always wrap the DAO
calls in the service layer in iBATIS transaction management code.  If there
was an external transaction manager, that code would be ignored.  If there
was not an external transaction manager, then using the iBATIS transaction
API would guarantee a single transaction for each service method (a good
idea IMHO).

So I think the jpetstore example is not really correct in this instance.

BTW - I would always control transactions in the service layer, never in the
DAO layer.  This will work well with Abator too.

Jeff Butler

On 3/6/06, Tony Qian <daqiqian2@aol.com> wrote:
> Jean-Francois Poilpret wrote on 3/6/2006, 10:40 AM:
> in AccountService.java
>  public void insertAccount(Account account) {
>     accountDao.insertAccount(account);
>   }
> Thank you very much for your response.  Do you know if  above code
> guarantee an atomic transaction in iBATIS?  accountDao.insertAccount(account)
> calls three updates (more accurately three inserts to different tables).
> thanks,
> Tony

View raw message