I am trying to run a custom sql on a batch session object
@Insert("INSERT INTO ticker(Ticker, GetUpdate) VALUES(#{symbol}, 1) ON DUPLICATE KEY UPDATE GetUpdate = 1")
void enableQuoteforSymbol(@Param("symbol") String symbol);
but my following code, which is responsible for flushing and committing the batches have some mysterious behavior
while(true == continueProcessing.get())
{
List<BatchResult> batchResult;
try
{
batchResult = batchSqlSession.flushStatements();
if(batchResult.size() > 0 )
{
batchSqlSession.commit();
batchSqlSession.clearCache();
}
Thread.sleep(configurationManager.BATCH_COMMITER_DELAY);
}
catch (Exception ex)
{
logger.error("BatchService::run() - ", ex);
}
}
it executes perfectly and batchSqlSession.flushStatements() does give back number of executed statements. Despite of successful execution of previous batch, this code batchResult = batchSqlSession.flushStatements(); and batchSqlSession.commit(); reruns the same old batch in next iteration. why ?
Looks like it is a bug: http://code.google.com/p/mybatis/issues/detail?id=695
Aready fixed for the next version.