Hi Hycel,
I don't know if this will answer your question but i will try.
My DAO is defined this way
public class ShopSqlMapDao extends BaseSqlMapDao implements ShopDao
Just like in the JPetStore application.
When executing in batch mode i do this.
try {
startTransaction();
startBatch();
for (int i = 0; i < dealerFrLines.length; i++) {
param.put("dealerFrLines", new Integer(dealerFrLines[i]));
insert("insertShopDFL", param);
}
executeBatch();
commitTransaction();
} finally {
endTransaction();
}
The reason i use transaction is at line
insert("insertShopDFL", param);
is where the get connection happens to execute the query. By adding the start
and end
transaction, i will be using only one connection and not use different
connections to execute each
insert in the batch mode.
Hope this helps
Prashanth Sukumaran.
--- Hycel Taylor <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I apologize, if this is the second time my email appears on the forum.
> I didn't see the first one show up after I posted it and this is my
> first time posting on this forum. Also, the first time I posted this
> email, there were '3D' characters all in my code example. I don't
> know how they got there, so I removed them.
>
> I'm converting my home grown custom DAO's over to IBatis sqlMaps and
> the IBatis DAO's. I'm finding IBatis a lot simpler to use than my
> own. However, I need to do a lot of batch processing and I need to do
> it from the DAO tier. With my custom DAO manager, I simply passed the
> same connection to all the DAO's and batching was pretty transparent
> and simple. For example, I would instantiate my DAO's with the
> following code:
>
> private Connection destConnection;
> private SchoolDAO schoolDAO;
> private MajorDAO majorDAO;
> private CourseDAO courseDAO;
>
> destConnection =
> connectionFactory.getConnection
> (ServiceConnectionFactory.CUSTOM_CONNECTION);
>
> final ServiceConnection serviceConnection =
> new ServiceConnection(destConnection, true, "MaxDB");
>
> final DAOFactory daoFactory = new DAOFactory(serviceConnection);
>
> schoolDAO = (SchoolDAO) daoFactory.getDAO(DAOFactory.SCHOLE_DAO);
> majorDAO = (MajorDAO) daoFactory.getDAO(DAOFactory.MAJOR_DAO);
> courseDAO = (CourseDAO) daoFactory.getDAO(DAOFactory.COURSE_DAO);
>
> I would do insertions, updates or deletes using the given DAO's, for N
> (say 1000) iterations. Then I would use a method like the following
> to execute a batch.
>
> private void doBatchUpdate() throws SQLException {
> schoolDAO.executeBatch();
> majorDAO.executeBatch();
> courseDAO.executeBatch();
> destConnection.commit();
> destConnection.close();
> }
>
> This has been very powerful for me. Because no matter how complex my
> model and no matter how many DAO's I happen to be using, I can easily
> accomplish my task. I've even moved this capability up to my service
> tier. By passing in a connection at the service tier I have
> simplified my code even further because a given service class may one
> or more DAO's.
>
> I would like to have the same functionality using IBatis Data Access
> Objects. Currently, I don't understand how to do this using your DAO
> Manager. You have a clear example of how to do batching directly
> using SqlMaps. But, I need to be able to do batching at the DAO tier.
>
> Please, could you explain to me how I may do Batch processing using
> IBatis DAO's.
>
> Thank you.
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com