ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diran Ayandele <Adediran.Ayand...@Sun.COM>
Subject Re: faster updates
Date Thu, 11 May 2006 16:29:59 GMT
Or, you could even leave batch size to your dao:

    protected int executeBatch(String statementName, List objectsToLoad) {
    SqlMapExecutor sqlMap = getSqlMapExecutor();
    try {
   
         //add simple logic to go in increments of x here.

        sqlMap.startBatch();
        for(int i=0; i< objectsToLoad.size(); i++) {
        sqlMap.update(statementName, objectsToLoad.get(i));
        }
        return sqlMap.executeBatch();
        //   end

        throw new DaoException("Error executing batch.  Cause: " + e, e);
    }
    }

Nathan Maves wrote:

> Not sure if I understand your problem but here goes ...
>
> In my service layer I would put together a LIst of your objects to be  
> updated.  Say maybe a 1000 at a time.  When you List is full then I  
> would send this to the dao level and then add each object to the  
> batch.  Once everyone of the 1000 are in the batch execute it.
>
> This should be way faster then individual updates even with a  
> prepared statement.
>
> Nathan
>
> On May 10, 2006, at 3:50 PM, netsql wrote:
>
>> How do you batch update multiples if I discreatley call each update?
>>
>> Do begin trn/end tarn on a timer?
>>
>> .V
>>
>> Nathan Maves wrote:
>>
>>>   I would suggest trying a batch insert/update first.
>>
>>
>

Mime
View raw message