List of usage examples for org.apache.ibatis.mapping MappedStatement getStatementLog
public Log getStatementLog()
From source file:com.luxoft.mybatis.splitter.ReusingBatchExecutor.java
License:Apache License
public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException { final Configuration configuration = ms.getConfiguration(); final StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null, null); final BoundSql boundSql = handler.getBoundSql(); PreparedStatementKey key = new PreparedStatementKey(boundSql.getSql(), ms); StatementData statementData = statementsData.get(key); if (retainExecuteOrder && statementData != null && !key.equals(lastKey)) { statementData = null;/* www .ja v a 2 s .c om*/ executeUpTo(key, true); } if (statementData == null) { statementData = unusedStatementData.remove(key); if (statementData == null) { Connection connection = getConnection(ms.getStatementLog()); Statement stmt = handler.prepare(connection); statementData = new StatementData(stmt); } statementsData.put(key, statementData); } lastKey = key; statementData.addParameterObject(parameterObject); handler.parameterize(statementData.getStatement()); handler.batch(statementData.getStatement()); return BATCH_UPDATE_RETURN_VALUE; }
From source file:com.luxoft.mybatis.splitter.ReusingBatchExecutor.java
License:Apache License
public <E> List<E> doQuery(MappedStatement ms, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { Statement stmt = null;/*from ww w.jav a2s. co m*/ try { flushStatements(); Configuration configuration = ms.getConfiguration(); StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, rowBounds, resultHandler, boundSql); Connection connection = getConnection(ms.getStatementLog()); stmt = handler.prepare(connection); handler.parameterize(stmt); return handler.<E>query(stmt, resultHandler); } finally { closeStatement(stmt); } }
From source file:com.navercorp.pinpoint.web.dao.ibatis.BindingLogPlugin32.java
License:Apache License
private void bindingLog(Invocation invocation) throws SQLException { Object[] args = invocation.getArgs(); MappedStatement ms = (MappedStatement) args[0]; Object parameterObject = args[1]; StatementType statementType = ms.getStatementType(); if (StatementType.PREPARED == statementType || StatementType.CALLABLE == statementType) { Log statementLog = ms.getStatementLog(); if (isDebugEnable(statementLog)) { BoundSql boundSql = ms.getBoundSql(parameterObject); String sql = boundSql.getSql(); List<String> parameterList = getParameters(ms, parameterObject, boundSql); debug(statementLog, "==> BindingLog: " + bindLogFormatter.format(sql, parameterList)); }//from ww w. ja v a2 s . c o m } }