Search in sources :

Example 11 with SqlMapClient

use of com.ibatis.sqlmap.client.SqlMapClient in project pinpoint by naver.

the class SqlMapClientIT method updateShouldBeTraced.

@Test
public void updateShouldBeTraced() throws Exception {
    SqlMapClient sqlMapClient = new SqlMapClientImpl(super.mockSqlMapExecutorDelegate);
    super.testAndVerifyUpdate(sqlMapClient);
}
Also used : SqlMapClientImpl(com.ibatis.sqlmap.engine.impl.SqlMapClientImpl) SqlMapClient(com.ibatis.sqlmap.client.SqlMapClient) Test(org.junit.Test)

Example 12 with SqlMapClient

use of com.ibatis.sqlmap.client.SqlMapClient in project camel by apache.

the class IBatisProducer method doQueryForList.

private void doQueryForList(Exchange exchange) throws Exception {
    SqlMapClient client = endpoint.getSqlMapClient();
    Object result;
    Object in = exchange.getIn().getBody();
    if (in != null) {
        LOG.trace("QueryForList: {} using statement: {}", in, statement);
        result = client.queryForList(statement, in);
    } else {
        LOG.trace("QueryForList using statement: {}", statement);
        result = client.queryForList(statement);
    }
    doProcessResult(exchange, result);
}
Also used : SqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)

Example 13 with SqlMapClient

use of com.ibatis.sqlmap.client.SqlMapClient in project camel by apache.

the class IBatisProducer method doQueryForObject.

private void doQueryForObject(Exchange exchange) throws Exception {
    SqlMapClient client = endpoint.getSqlMapClient();
    Object result;
    Object in = exchange.getIn().getBody();
    if (in != null) {
        LOG.trace("QueryForObject: {} using statement: {}", in, statement);
        result = client.queryForObject(statement, in);
    } else {
        LOG.trace("QueryForObject using statement: {}", statement);
        result = client.queryForObject(statement);
    }
    doProcessResult(exchange, result);
}
Also used : SqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)

Example 14 with SqlMapClient

use of com.ibatis.sqlmap.client.SqlMapClient in project camel by apache.

the class IBatisProducer method doUpdate.

private void doUpdate(Exchange exchange) throws Exception {
    SqlMapClient client = endpoint.getSqlMapClient();
    Object result;
    Object in = exchange.getIn().getBody();
    if (in != null) {
        // lets handle arrays or collections of objects
        Iterator<?> iter = ObjectHelper.createIterator(in);
        while (iter.hasNext()) {
            Object value = iter.next();
            LOG.trace("Updating: {} using statement: {}", value, statement);
            result = client.update(statement, value);
            doProcessResult(exchange, result);
        }
    } else {
        LOG.trace("Updating using statement: {}", statement);
        result = client.update(statement);
        doProcessResult(exchange, result);
    }
}
Also used : SqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)

Example 15 with SqlMapClient

use of com.ibatis.sqlmap.client.SqlMapClient in project camel by apache.

the class DefaultIBatisProcessingStategy method commit.

public void commit(IBatisEndpoint endpoint, Exchange exchange, Object data, String consumeStatements) throws Exception {
    SqlMapClient client = endpoint.getSqlMapClient();
    boolean useTrans = endpoint.isUseTransactions();
    String[] statements = consumeStatements.split(",");
    try {
        if (useTrans) {
            client.startTransaction(isolation);
        }
        for (String statement : statements) {
            client.update(statement.trim(), data);
        }
        if (useTrans) {
            client.commitTransaction();
        }
    } finally {
        if (useTrans) {
            client.endTransaction();
        }
    }
}
Also used : SqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)

Aggregations

SqlMapClient (com.ibatis.sqlmap.client.SqlMapClient)15 Test (org.junit.Test)9 SqlMapClientImpl (com.ibatis.sqlmap.engine.impl.SqlMapClientImpl)8 SQLException (java.sql.SQLException)1 Anotherawfultable (mbg.test.ib2j5.generated.miscellaneous.model.Anotherawfultable)1