ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregg D Bolinger <gthou...@gmail.com>
Subject Re: DAO and Batch in Single Transaction
Date Thu, 05 May 2005 20:13:04 GMT
I actually talked about this approach with a colleague just last
night.  We are using a singleton for our daoManager so this would work
perfectly, I think.  I'll try it out and let you know.

On 5/4/05, Clinton Begin <clinton.begin@gmail.com> wrote:
> Oops....forgot to mention another pattern...
>  
>  One thing you can do is have a BatchDAO which basically just defines two
> methods:  startBatch and endBatch.  Then you could do:
>  
>  daoManager.startTransaction()
>  batchDao.startBatch()
>  someDao.insert()
>  someOtherDao.update()
>  anotherDao.delete()
>  batchDao.endBatch()
>  daoManager.commitTransaction()
>  
>  That would give you the flexibility of batching in some cases, but not all.
>  You could even delegate the call to daoManager.startTransaction() and
> batchDao.startBatch() to a base service method, so you wouldn't always have
> to call both.  I typically put such methods in around advice or just a
> simple dynamic proxy at my service layer.
>  
>  Cheers,
>  Clinton
> 
> 
> On 5/4/05, Clinton Begin <clinton.begin@gmail.com> wrote:
> > 
> > That is actually an option.  I thought about adding that in 2.0, and IIRC
> it wouldn't be hard to add.  
> > 
> > Of course, you'd have to live with the challenges of what basically
> amounts to a write cache.  That is, in this scenario:
> > 
> > start TX
> > insert into PEOPLE
> > select from PEOPLE
> > end TX
> > select from PEOPLE
> > 
> > ...the result of the first insert would not be seen by the first select,
> but would be seen by the second.
> > 
> > Cheers,
> > Clinton
> > 
> > 
> > 
> > On 5/4/05, Gregg D Bolinger < gthought@gmail.com> wrote:
> > > Well, my approach won't work.  You can't get to the startBatch from
> > > the service.  DaoManager only handles transactions.  SqlMpa handles
> > > batching.  So the batches have to be done in the DAO which makes it
> > > impossible to batch more than one DAO. 
> > > 
> > > What would be nice is if iBatis just batched transactions by default.
> > > 
> > > On 5/4/05, Clinton Begin < clinton.begin@gmail.com> wrote:
> > > >
> > > >  Your approach sounds good.  I wouldn't try to overcomplicate this. 
> > > >
> > > >  Cheers,
> > > >  Clinton
> > > >
> > > >
> > > > On 5/2/05, Gregg D Bolinger <gthought@gmail.com > wrote:
> > > > > I am using iBatis SqlMap and iBatis DAO. I am trying to look into

> > > > > doing batch inserts/updates/delete within a single transaction for
> > > > > multiple DAO's.  So should I create a Service that just handles my
> > > > > batches and has an instance of each DAO that it needs, or is there
a
> > > > > different way?  Anyone have any tips or hints on doing this?
> > > > >
> > > > > Thanks.
> > > > >
> > > >
> > > >
> > > 
> > > 
> > 
> > 
> 
>

Mime
View raw message