• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SqlMapClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testSqlMapClientDaoSupport

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Test
public void testSqlMapClientDaoSupport() throws Exception {
	DataSource ds = mock(DataSource.class);
	SqlMapClientDaoSupport testDao = new SqlMapClientDaoSupport() {
	};
	testDao.setDataSource(ds);
	assertEquals(ds, testDao.getDataSource());

	SqlMapClient client = mock(SqlMapClient.class);

	testDao.setSqlMapClient(client);
	assertEquals(client, testDao.getSqlMapClient());

	SqlMapClientTemplate template = new SqlMapClientTemplate();
	template.setDataSource(ds);
	template.setSqlMapClient(client);
	testDao.setSqlMapClientTemplate(template);
	assertEquals(template, testDao.getSqlMapClientTemplate());

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


示例17: setUp

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Before
public void setUp() {
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    sqlMapClientTemplate = mock(SqlMapClientTemplate.class);
    stageSqlMapDao = new StageSqlMapDao(mock(JobInstanceSqlMapDao.class), new Cache(true, false, false), mock(TransactionTemplate.class), mock(SqlMapClient.class), goCache,
            mock(TransactionSynchronizationManager.class), mock(SystemEnvironment.class), null);
    stageSqlMapDao.setSqlMapClientTemplate(sqlMapClientTemplate);
    cloner = mock(Cloner.class);
    ReflectionUtil.setField(stageSqlMapDao, "cloner", cloner);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return invocationOnMock.getArguments()[0];
        }
    }).when(cloner).deepClone(anyObject());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:StageSqlMapDaoTest.java


示例18: JobInstanceSqlMapDao

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Autowired
public JobInstanceSqlMapDao(EnvironmentVariableDao environmentVariableDao, GoCache goCache, TransactionTemplate transactionTemplate, SqlMapClient sqlMapClient, Cache cache,
                            TransactionSynchronizationManager transactionSynchronizationManager, SystemEnvironment systemEnvironment, Database database,
                            ResourceRepository resourceRepository, ArtifactPlanRepository artifactPlanRepository, ArtifactPropertiesGeneratorRepository artifactPropertiesGeneratorRepository,
                            JobAgentMetadataDao jobAgentMetadataDao) {
    super(goCache, sqlMapClient, systemEnvironment, database);
    this.environmentVariableDao = environmentVariableDao;
    this.goCache = goCache;
    this.transactionTemplate = transactionTemplate;
    this.cache = cache;
    this.transactionSynchronizationManager = transactionSynchronizationManager;
    this.resourceRepository = resourceRepository;
    this.artifactPlanRepository = artifactPlanRepository;
    this.artifactPropertiesGeneratorRepository = artifactPropertiesGeneratorRepository;
    this.jobAgentMetadataDao = jobAgentMetadataDao;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:JobInstanceSqlMapDao.java


示例19: insert

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Override
public Object insert(Object shardingId, String sqlMapId, boolean afterInvoke) throws Exception {

	Object result = null;

	String[] array = getShardingArray(shardingId);
	if (null != array && 0 < array.length) {
		String dbName = array[0];
		SqlMapClient sqlMapClient = shardingStrategy.getSqlMapClientByDbName(dbName);
		if (null != sqlMapClient) {
			result = sqlMapClient.insert(sqlMapId);
		}
	}

	if (afterInvoke) {
		afterInvoke(ShardingConfig.DB_OPTYPE_INSERT, result, shardingId, null);
	}

	return result;
}
 
开发者ID:wangym,项目名称:koubei-sharding,代码行数:21,代码来源:BaseShardingDAO.java


示例20: update

import com.ibatis.sqlmap.client.SqlMapClient; //导入依赖的package包/类
@Override
public int update(Object shardingId, String sqlMapId, boolean afterInvoke) throws Exception {

	int result = -1;

	String[] array = getShardingArray(shardingId);
	if (null != array && 0 < array.length) {
		String dbName = array[0];
		SqlMapClient sqlMapClient = shardingStrategy.getSqlMapClientByDbName(dbName);
		if (null != sqlMapClient) {
			result = sqlMapClient.update(sqlMapId);
		}
	}

	if (afterInvoke) {
		afterInvoke(ShardingConfig.DB_OPTYPE_UPDATE, result, shardingId, null);
	}

	return result;
}
 
开发者ID:wangym,项目名称:koubei-sharding,代码行数:21,代码来源:BaseShardingDAO.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TitanGraph类代码示例发布时间:2022-05-21
下一篇:
Java StringPrepDataReader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap