ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Zimowski" <zimowsk...@gmail.com>
Subject Re: Array or List in a ParameterClass
Date Tue, 25 Sep 2007 18:30:29 GMT
It sounds like what you really want to do is a batched update
(developer's guide pages 55-57). You don't need to pass in the array
or a list, you simply pass in a bean instance or a parameter map for a
single update. You start a batch inside a transaction, make your 1000
updates, then you call execute batch. Example from dev guide:

try {
  sqlMap.startTransaction();
  sqlMap.startBatch();
  // … execute statements in between
  int rowsUpdated = sqlMap.executeBatch(); //optional
  sqlMap.commitTransaction();
} finally {
  sqlMap.endTransaction();
}

If you use something like Spring to do your transactions you may have
to do some abstract base classes to cover the boilerplate code, but
I'd keep things simple and get everything working in iBatis natively.
For all I know, you may want to use iBatis for entire DAO layer.

Hope this helps.
-adam

On 9/25/07, Christopher Lamey <clamey@localmatters.com> wrote:
> Hello,
>
> Take a look at pages 49 and 50 of the developer's guide.  It has examples of
> what you're trying to do.
>
>      http://ibatis.apache.org/docs/java/pdf/iBATIS-SqlMaps-2_en.pdf
>
> Cheers,
> Chris
>
> On 9/25/07 11:45 AM, "Felipe Maza" <felipe@felipem.com> wrote:
>
> > Hi,
> >
> > I'm trying send a array to ibatis for do multiple updates in a sentence
> >
> > I read examples of <iterate> for List, but i don't know how apply to my xml
> >
> >
> >
> >
> > for example, i have some users for update
> >
> > <update id="example" parameterClass="???">
> >     update users set user= ??? where id_user= ???
> > </update>
> >
> >
> >
> >
> > other solution is do a bucle in the DAO, but i need do more 1000 updates and
> > this system is more slow for the server and bbdd :(
> >
> > thanks.
>
>

Mime
View raw message