当前位置: 首页>>代码示例>>Java>>正文


Java SqlMapClient类代码示例

本文整理汇总了Java中com.ibatis.sqlmap.client.SqlMapClient的典型用法代码示例。如果您正苦于以下问题:Java SqlMapClient类的具体用法?Java SqlMapClient怎么用?Java SqlMapClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlMapClient类属于com.ibatis.sqlmap.client包,在下文中一共展示了SqlMapClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInsert

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
private void doInsert(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("Inserting: {} using statement: {}", value, statement);
            result = client.insert(statement, value);
            doProcessResult(exchange, result);
        }
    } else {
        LOG.trace("Inserting using statement: {}", statement);
        result = client.insert(statement);
        doProcessResult(exchange, result);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:IBatisProducer.java

示例2: doUpdate

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:IBatisProducer.java

示例3: doDelete

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
private void doDelete(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("Deleting: {} using statement: {}", value, statement);
            result = client.delete(statement, value);
            doProcessResult(exchange, result);
        }
    } else {
        LOG.trace("Deleting using statement: {}", statement);
        result = client.delete(statement);
        doProcessResult(exchange, result);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:IBatisProducer.java

示例4: commit

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:DefaultIBatisProcessingStategy.java

示例5: exceptionsThrownShouldBeTraced

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void exceptionsThrownShouldBeTraced() throws Exception {
    // Given
    when(this.mockSqlMapExecutorDelegate.beginSessionScope()).thenReturn(null);
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    try {
        sqlMapClient.insert("insertShouldThrowNPE");
        fail("sqlMapClient.insert should throw NullPointerException");
    } catch (NullPointerException e) {
        // Then
        final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
        assertThat(spanEvents.size(), is(1));
        final SpanEventBo exceptionSpanEventBo = spanEvents.get(0);
        assertThat(exceptionSpanEventBo.hasException(), is(true));
        assertThat(exceptionSpanEventBo.getExceptionId(), not(0));
    }
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:19,代码来源:SqlMapClientImplModifierTest.java

示例6: nullParametersShouldNotBeTraced

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void nullParametersShouldNotBeTraced() throws Exception {
    // Given
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    sqlMapClient.insert(null);
    sqlMapClient.queryForList(null);
    // Then
    final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
    assertThat(spanEvents.size(), is(2));

    // Check Method
    final SpanEventBo insertSpanEventBo = spanEvents.get(0);
    final SpanEventBo queryForListSpanEventBo = spanEvents.get(1);
    assertThat(insertSpanEventBo.getApiId(), not(0));
    assertThat(queryForListSpanEventBo.getApiId(), not(0));
    assertThat(insertSpanEventBo.getApiId(), not(queryForListSpanEventBo.getApiId()));

    // Check Parameter
    assertNull(insertSpanEventBo.getAnnotationBoList());
    assertNull(queryForListSpanEventBo.getAnnotationBoList());
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:23,代码来源:SqlMapClientImplModifierTest.java

示例7: sameApiCallsShouldHaveTheSameApiId

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void sameApiCallsShouldHaveTheSameApiId() throws Exception {
    // Given
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    sqlMapClient.insert("insertA");
    sqlMapClient.insert("insertB");
    // Then
    final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
    assertThat(spanEvents.size(), is(2));

    // Check Method
    final SpanEventBo insertASpanEventBo = spanEvents.get(0);
    final SpanEventBo insertBSpanEventBo = spanEvents.get(1);
    assertThat(insertASpanEventBo.getApiId(), not(0));
    assertThat(insertBSpanEventBo.getApiId(), not(0));
    assertThat(insertASpanEventBo.getApiId(), is(insertBSpanEventBo.getApiId()));

}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:20,代码来源:SqlMapClientImplModifierTest.java

示例8: queryForListShouldBeTraced

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void queryForListShouldBeTraced() throws Exception {
    // Given
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    sqlMapClient.queryForList("abc");
    // Then
    final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
    assertThat(spanEvents.size(), is(1));

    // Check Method
    final SpanEventBo apiCallSpanEventBo = spanEvents.get(0);
    assertThat(apiCallSpanEventBo.getApiId(), not(0));

    // Check Parameter
    final List<AnnotationBo> annotationBoList = apiCallSpanEventBo.getAnnotationBoList();
    assertThat(annotationBoList.size(), is(1));

    final AnnotationBo parameterAnnotationBo = annotationBoList.get(0);
    assertThat(parameterAnnotationBo.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:22,代码来源:SqlMapClientImplModifierTest.java

示例9: queryForObjectShouldBeTraced

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void queryForObjectShouldBeTraced() throws Exception {
    // Given
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    sqlMapClient.queryForObject("abrgrgfdaghertah", new Object());
    // Then
    final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
    assertThat(spanEvents.size(), is(1));

    // Check Method
    final SpanEventBo apiCallSpanEventBo = spanEvents.get(0);
    assertThat(apiCallSpanEventBo.getApiId(), not(0));

    // Check Parameter
    final List<AnnotationBo> annotationBoList = apiCallSpanEventBo.getAnnotationBoList();
    assertThat(annotationBoList.size(), is(1));

    final AnnotationBo parameterAnnotationBo = annotationBoList.get(0);
    assertThat(parameterAnnotationBo.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:22,代码来源:SqlMapClientImplModifierTest.java

示例10: getSqlMapClient

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
protected SqlMapClient getSqlMapClient() throws FeedServerAdapterException {
  String dataSourceId = config.getFeedConfigLocation();
  if (sqlMapClients.containsKey(dataSourceId)) {
    return sqlMapClients.get(dataSourceId);
  } else {
    SqlMapClient client;
    try {
      client =
          SqlMapClientBuilder.buildSqlMapClient(config.getAdapterConfiguration()
              .getAdapterConfigAsReader());
    } catch (IOException e) {
      throw new FeedServerAdapterException(
          FeedServerAdapterException.Reason.ADAPTER_CONFIGURATION_NOT_CORRECT, dataSourceId);
    }
    sqlMapClients.put(dataSourceId, client);
    return client;
  }
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:19,代码来源:IBatisCollectionAdapter.java

示例11: retrieveFeed

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Feed retrieveFeed(RequestContext request) throws FeedServerAdapterException {
  SqlMapClient client = getSqlMapClient();
  String queryId = config.getFeedId() + "-get-feed";
  List<Map<String, Object>> rows;
  try {
    rows = client.queryForList(queryId, getRequestParams(request));
  } catch (SQLException e) {
    throw new FeedServerAdapterException(
        FeedServerAdapterException.Reason.ERROR_EXECUTING_ADAPTER_REQUEST, e.getMessage());
  }
  Feed feed = createFeed();
  ServerConfiguration serverConfig = config.getServerConfiguration();
  if (serverConfig.getFeedNamespacePrefix() != null
      && serverConfig.getFeedNamespacePrefix().length() > 0) {
    feed.declareNS(serverConfig.getFeedNamespace(), serverConfig.getFeedNamespacePrefix());
  }
  for (Map<String, Object> row : rows) {
    createEntryFromProperties(feed, row);
  }
  return feed;
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:24,代码来源:IBatisCollectionAdapter.java

示例12: retrieveEntry

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Entry retrieveEntry(RequestContext request, Object entryId)
    throws FeedServerAdapterException {
  String queryId = config.getFeedId() + "-get-entry";
  SqlMapClient client = getSqlMapClient();
  Map<String, Object> row;
  try {
    row = (Map<String, Object>) client.queryForObject(queryId, entryId,  getRequestParams(request));
  } catch (SQLException e) {
    throw new FeedServerAdapterException(
        FeedServerAdapterException.Reason.ERROR_EXECUTING_ADAPTER_REQUEST, e.getMessage());
  }
  if (row == null) {
    // didn't find the entry.
    return null;
  }
  return createEntryFromProperties(null, row);
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:20,代码来源:IBatisCollectionAdapter.java

示例13: deleteEntry

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Override
public void deleteEntry(RequestContext request, Object entryId) throws FeedServerAdapterException {
  String queryId = config.getFeedId() + "-delete-entry";
  SqlMapClient client = getSqlMapClient();
  try {
    Map<String, Object> params = getRequestParams(request);
    params.put("id", entryId);
    if (!(client.delete(queryId, params) > 0)) {
      throw new FeedServerAdapterException(
          FeedServerAdapterException.Reason.ERROR_EXECUTING_ADAPTER_REQUEST, "could not delete");
    }
  } catch (SQLException e) {
    throw new FeedServerAdapterException(
        FeedServerAdapterException.Reason.ERROR_EXECUTING_ADAPTER_REQUEST, e.getMessage());
  }
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:17,代码来源:IBatisCollectionAdapter.java

示例14: testSqlMapClientTemplateWithNestedSqlMapSession

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void testSqlMapClientTemplateWithNestedSqlMapSession() throws SQLException {
	DataSource ds = mock(DataSource.class);
	final Connection con = mock(Connection.class);
	final SqlMapSession session = mock(SqlMapSession.class);
	SqlMapClient client = mock(SqlMapClient.class);

	given(client.openSession()).willReturn(session);
	given(session.getCurrentConnection()).willReturn(con);

	SqlMapClientTemplate template = new SqlMapClientTemplate();
	template.setDataSource(ds);
	template.setSqlMapClient(client);
	template.afterPropertiesSet();
	Object result = template.execute(new SqlMapClientCallback() {
		@Override
		public Object doInSqlMapClient(SqlMapExecutor executor) {
			assertTrue(executor == session);
			return "done";
		}
	});
	assertEquals("done", result);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:SqlMapClientTests.java

示例15: testQueryForObjectOnSqlMapSession

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void testQueryForObjectOnSqlMapSession() throws SQLException {
	DataSource ds = mock(DataSource.class);
	Connection con = mock(Connection.class);
	SqlMapClient client = mock(SqlMapClient.class);
	SqlMapSession session = mock(SqlMapSession.class);

	given(ds.getConnection()).willReturn(con);
	given(client.getDataSource()).willReturn(ds);
	given(client.openSession()).willReturn(session);
	given(session.queryForObject("myStatement", "myParameter")).willReturn("myResult");

	SqlMapClientTemplate template = new SqlMapClientTemplate();
	template.setSqlMapClient(client);
	template.afterPropertiesSet();
	assertEquals("myResult", template.queryForObject("myStatement", "myParameter"));

	verify(con).close();
	verify(session).setUserConnection(con);
	verify(session).close();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:SqlMapClientTests.java


注:本文中的com.ibatis.sqlmap.client.SqlMapClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。