You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jesse Reimann <jr...@ctigroup.com> on 2008/03/05 16:19:04 UTC

iBATIS Batching with Spring DAO

Could someone explain to me how-to do iBATIS batching when using Spring
DAO? I've been reading and searching and can't seem to find an example
out there on how to actually do it.

I'm using Abator to generate my Spring DAO classes and I've got it
working with no issues. I read that using Spring that you are
effectively setting the TransactionManager type to EXTERNAL so I also
setup a Spring Transaction Manager as discussed in this thread:
http://markmail.org/message/cjqctvogweyoykih . 

 

Has anyone else implemented batching in iBATIS with a similar setup and
can point me in the right direction?

 

 

Thanks,

 

Jesse Reimann

 

 


RE: iBATIS Batching with Spring DAO

Posted by Poitras Christian <Ch...@ircm.qc.ca>.
You have an example here: http://static.springframework.org/spring/docs/2.5.x/reference/orm.html#orm-ibatis-template

Christian


________________________________
From: Jesse Reimann [mailto:jreimann@ctigroup.com]
Sent: Wednesday, March 05, 2008 10:19 AM
To: user-java@ibatis.apache.org
Subject: iBATIS Batching with Spring DAO

Could someone explain to me how-to do iBATIS batching when using Spring DAO? I've been reading and searching and can't seem to find an example out there on how to actually do it.
I'm using Abator to generate my Spring DAO classes and I've got it working with no issues. I read that using Spring that you are effectively setting the TransactionManager type to EXTERNAL so I also setup a Spring Transaction Manager as discussed in this thread: http://markmail.org/message/cjqctvogweyoykih .

Has anyone else implemented batching in iBATIS with a similar setup and can point me in the right direction?


Thanks,

Jesse Reimann



RE: iBATIS Batching with Spring DAO

Posted by Jesse Reimann <jr...@ctigroup.com>.
Thanks for the help. I had seen that code example before but not from
the Spring doc so didn't understand the context. After playing with it
for a bit I was able to get some test code working with the batching
using that method.

 

I don't know if it's my environment config or what but I had to make a
couple tweaks to get the example code to work

I had to make the Account final so the inner class could access it and
also have the inner class return an object.

I'm new to Java (I have a C++ and C# background) so still trying to get
a handle on the language as well as all these frameworks.

 

public class SqlMapAccountDao extends SqlMapClientDaoSupport implements
AccountDao {
 
    public void insertAccount(final Account account) throws
DataAccessException {
        getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
            public Object doInSqlMapClient(SqlMapExecutor executor)
throws SQLException {
                executor.startBatch();
                executor.update("insertAccount", account);
                executor.update("insertAddress", account.getAddress());
                return executor.executeBatch();
            }
        });
    }
}

 

 


RE: iBATIS Batching with Spring DAO

Posted by Chris McMahon <co...@hotmail.com>.
It's interesting that they use that as an example, because that wouldn't even really do a batch.  In recent discussions, it was shown that iBATIS only batches the same statements.  "insertAccount" and "insertAddress" would likely not be the same SQL statement, so they would each be in their own batch.



Subject: RE: iBATIS Batching with Spring DAO
Date: Wed, 5 Mar 2008 08:41:19 -0700
From: Sundar.Sankaranarayanan@phoenix.edu
To: user-java@ibatis.apache.org










Did u check Spring-reference.pdf. The batching of Ibatis 
has been explained in page 296. 
 

public class SqlMapAccountDao extends SqlMapClientDaoSupport 
implements AccountDao {
public void insertAccount(Account account) throws 
DataAccessException {
getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws 
SQLException {
executor.startBatch();
executor.update("insertAccount", account);
executor.update("insertAddress", account.getAddress());
executor.executeBatch();
}
});
}
}
 
-S



From: Jesse Reimann 
[mailto:jreimann@ctigroup.com] 
Sent: Wednesday, March 05, 2008 8:19 
AM
To: user-java@ibatis.apache.org
Subject: iBATIS Batching 
with Spring DAO




Could someone explain to me how-to 
do iBATIS batching when using Spring DAO? I’ve been reading and searching and 
can’t seem to find an example out there on how to actually do 
it.
I’m using Abator to generate my 
Spring DAO classes and I’ve got it working with no issues. I read that using 
Spring that you are effectively setting the TransactionManager type to EXTERNAL 
so I also setup a Spring Transaction Manager as discussed in this thread: http://markmail.org/message/cjqctvogweyoykih 
. 
 
Has anyone else implemented batching 
in iBATIS with a similar setup and can point me in the right 
direction?
 
 
Thanks,
 
Jesse 
Reimann
 
 

_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/

RE: iBATIS Batching with Spring DAO

Posted by Sundar Sankaranarayanan <Su...@phoenix.edu>.
Did u check Spring-reference.pdf. The batching of Ibatis has been
explained in page 296. 
 
public class SqlMapAccountDao extends SqlMapClientDaoSupport implements
AccountDao {

public void insertAccount(Account account) throws DataAccessException {

getSqlMapClientTemplate().execute(new SqlMapClientCallback() {

public Object doInSqlMapClient(SqlMapExecutor executor) throws
SQLException {

executor.startBatch();

executor.update("insertAccount", account);

executor.update("insertAddress", account.getAddress());

executor.executeBatch();

}

});

}

}

 

-S


________________________________

From: Jesse Reimann [mailto:jreimann@ctigroup.com] 
Sent: Wednesday, March 05, 2008 8:19 AM
To: user-java@ibatis.apache.org
Subject: iBATIS Batching with Spring DAO



Could someone explain to me how-to do iBATIS batching when using Spring
DAO? I've been reading and searching and can't seem to find an example
out there on how to actually do it.

I'm using Abator to generate my Spring DAO classes and I've got it
working with no issues. I read that using Spring that you are
effectively setting the TransactionManager type to EXTERNAL so I also
setup a Spring Transaction Manager as discussed in this thread:
http://markmail.org/message/cjqctvogweyoykih . 

 

Has anyone else implemented batching in iBATIS with a similar setup and
can point me in the right direction?

 

 

Thanks,

 

Jesse Reimann