ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <lmead...@apache.org>
Subject Re: Transaction trouble
Date Mon, 14 Nov 2005 13:14:51 GMT
Why are you doing this? It makes no sense.

The purpose of the DAO pattern is to eliminate this kind of thing from
your application.

Write one method in your DAO to do all of this, and be done with it.

Larry


On 11/14/05, Corneliu Rudeanu <crudeanu@yahoo.com> wrote:
>
> My intention is to mix SQL Mapper statements with DAO accesses in the
> same transaction. My code could look like this:
>
> sqlMapClient.startTransaction();
> sqlMapClient.update("updateUser", theUser);
> daoManager.getDao(UserDAO.class).load(theUser);
> sqlMapClient.commitTransaction();
> sqlMapClient.endTransaction();
>
> with:
> public class UserDAOImpl extends SqlMapDaoTemplate implements UserDAO {
>     public User load(String id) throws DaoException {
>         return (UserTag) queryForObject("loadUser", id);
>     }
> }
>
> DaoManager is configured like this:
> <daoConfig>
>     <context>
>         <transactionManager type="SQLMAP">
>             <property name="SqlMapConfigResource"
> value="some/domain/sql-map-config.xml"/>
>         </transactionManager>
>         <dao interface="some.domain.UserTagDAO"
> implementation="some.domain.UserDAOImpl"/>
>     </context>
> </daoConfig>
>
> sql-map-config.xml is used to build sqlMapClient. This way, I intended
> that both sqlMapClient and daoManager to share the same
> connection/transaction. But the code proves that they are not: the
> update made via sqlMapClient is not read via DAO. Splitting the two
> calls in separate transactions (with a commit after the first update)
> works ok.
>
> Please advise me: what am I missing? What should I do to get the
> sqlMapClient and daoManager share the same transaction?
>
> Thanks in advance,
> Corneliu Rudeanu
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
>

Mime
View raw message