I know the API state "A thread safe client for working with your SQL Maps", but I want to understand how it works a little better and was wondering if anyone was running this ina multi-threaded environment with transactions. For instance using:
void doSomeSql() throws SQLException{
sqlMapper.startTransaction();
sqlMapper.startBatch();
final Map paramMap = new HashMap();
paramMap.put("data", "data");
Integer num = (Integer) sqlMapper.queryForObject("getRowCount", paramMap);//get row count
sqlMapper.insert("insertData", paramMap); //insert row
num = (Integer) sqlMapper.queryForObject("getRowCount", paramMap);//get row count again
sqlMapper.executeBatch();
sqlMapper.commitTransaction();
}
If this was used on where multiple threads can call this and there is only one shared sqlMapper object would there be some threads that are executing the batch because another thread called executeBatch()? This becomes more of an issue if I have lots of other methods doing delete's updates etc using the same sqlMapper in other threads.
I dont want start a transaction in one thread, and have another thread commit before the previous thread was done.
I understand I can synchronize on all this, but would rather not have to.