I found out that all the problems I was having with OutOfMemoryErrors was
related directly to the Java Proxy in my own code and not iBatis...my
apologies.
Outside of that...thanks for the help. I was able to do a successful batch
implementation. When I excluded the
startTransaction/commitTransaction/endTransaction...my process took 5
minutes to run. When I included it, I got my full process to run under 1
minute. This is directly equal to the speed I found when using straight
Jdbc and/or Spring Jdbc Templates.
This is Awesome!!! And thank you so much for the responses. I love the
ease of configuration for connections and the fact that I can flip a sqlMap
config name (in my properties file) and load a Jndi Based
Connection/Transaction Manager (for running inside the container in
production) and then flip the name to load a Jdbc Connection Manager (for
running tests outside the container in development). That is huge!!! And
without any Java code modifications. I have been dreaming of this day!
Here is my batch method used with iBatis for doing the same thing in Jdbc as
addBatch/executeBatch for every 100 records in a list of records. That way
I use the speed of batching, without chancing an overflow of the
PreparedStatement/Connection with too much batched data.
private Object batch(SqlMapClient sqlMap, int batchType, String
methodName, Object argument) {
int commitSize = 100;
boolean commitBatch = false;
int totalRecordsUpdated = 0;
int commitBatchUpdated = 0;
try {
List list = (List)argument;
sqlMap.startTransaction();
sqlMap.startBatch();
for(int i = 0; i < list.size(); i++) {
if(batchType == INSERT) {
sqlMap.insert(methodName, list.get(i));
}
else if(batchType == DELETE) {
sqlMap.delete(methodName, list.get(i));
}
else if(batchType == UPDATE) {
sqlMap.update(methodName, list.get(i));
}
if((i != 0) && (i % commitSize == 0)) {
commitBatch = true;
}
else if(i == (list.size() - 1)) {
commitBatch = true;
}
if(commitBatch) {
commitBatchUpdated = sqlMap.executeBatch();
totalRecordsUpdated = totalRecordsUpdated +
commitBatchUpdated;
if(i != (list.size() - 1)) {
sqlMap.startBatch()
}
commitBatch = false;
}
}
sqlMap.commitTransaction();
validateBatchResult(methodName, new int[]{totalRecordsUpdated});
}
catch(SQLException e) {
exceptionConverter.rethrow(methodName, e);
}
finally {
try {
sqlMap.endTransaction();
}
catch(SQLException e) {
exceptionConverter.rethrow(methodName, e);
}
}
return new int[] {totalRecordsUpdated};
}
Thanks,
jay blanton
--
View this message in context:
http://www.nabble.com/executeBatch-not-returning-int-of-records-updated.-t1819686.html#a5006256
Sent from the iBATIS - User - Java forum at Nabble.com.