IBatis SqlMapClient Security and Thread Security

I know the state of the API "Stream Safe Client for Working with Your SQL Cards", but I want to understand how it works a little better, and wondered if anyone in this multi-threaded environment has transactions. For example, 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 when several threads can call this, and there is only one common sqlMapper object, will there be any threads executing the package because another thread is called executeBatch ()? This becomes a problem if I have many other ways to remove updates, etc., Using the same sqlMapper in other threads.

I do not want to start a transaction in one thread and commit another thread before the previous thread was executed.

, , .

+5
2

org.ibatis.sqlmap.engine.impl.SqlMapClientImpl ThreadLocal , SqlMapClient, .

+6

, , : DB.

+2

All Articles