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


Java SqlMapClient.insert方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: test

import com.ibatis.sqlmap.client.SqlMapClient; //导入方法依赖的package包/类
@Test(expected=NullPointerException.class)
public void test() throws SQLException {
    // Given
    when(this.mockSqlMapExecutorDelegate.beginSessionScope()).thenReturn(null);
    SqlMapClient sqlMapClient = new SqlMapClientImpl(this.mockSqlMapExecutorDelegate);
    // When
    sqlMapClient.insert("insertShouldThrowNPE");
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:9,代码来源:SqlMapClientImplModifierTest.java

示例7: insertShouldBeTraced

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

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

    // Check Parameter
    final List<AnnotationBo> insertWith1ArgAnnotations = insertWith1ArgSpanEventBo.getAnnotationBoList();
    assertThat(insertWith1ArgAnnotations.size(), is(1));
    final AnnotationBo insertWith1ArgParameterAnnotation = insertWith1ArgAnnotations.get(0);
    assertThat(insertWith1ArgParameterAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));

    final List<AnnotationBo> insertWith2ArgAnnotations = insertWith2ArgSpanEventBo.getAnnotationBoList();
    assertThat(insertWith2ArgAnnotations.size(), is(1));
    final AnnotationBo insertWith2ArgAnnotation = insertWith2ArgAnnotations.get(0);
    assertThat(insertWith2ArgAnnotation.getKey(), is(AnnotationKey.CACHE_ARGS0.getCode()));

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

示例8: createEntry

import com.ibatis.sqlmap.client.SqlMapClient; //导入方法依赖的package包/类
@Override
public Entry createEntry(RequestContext request, Entry entry) throws FeedServerAdapterException {
  SqlMapClient client = getSqlMapClient();
  String queryId = config.getFeedId() + "-insert-entry";
  Object newEntryId;
  try {
    Map<String, Object> params = getRequestParams(request);
    params.putAll(getPropertyMapForEntry(entry));
    newEntryId = client.insert(queryId, params);
  } catch (SQLException e) {
    throw new FeedServerAdapterException(
        FeedServerAdapterException.Reason.ERROR_EXECUTING_ADAPTER_REQUEST, e.getMessage());
  }
  return retrieveEntry(request, newEntryId);
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:16,代码来源:IBatisCollectionAdapter.java

示例9: testOrgSqlMapInsertTimeOut

import com.ibatis.sqlmap.client.SqlMapClient; //导入方法依赖的package包/类
@Test
public void testOrgSqlMapInsertTimeOut() throws Exception {

    if (!isHsql) {
        Reader reader =
            Resources
                .getResourceAsReader("META-INF/sqlmap/sql-map-config-org.xml");
        SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

        try {
            // insert ~ select
            sqlMap.insert("insertTestLargeTimeOut");

            fail("timeout 테스트이므로 더 시간이 많이 걸리는 쿼리를 사용해야 합니다.");
        } catch (Exception e) {
            assertNotNull(e);
            assertTrue(e instanceof SQLException);
            if (isOracle) {
                assertTrue(e.getMessage().contains("ORA-01013"));
            } else if (isMysql) {
                assertTrue(e.getMessage().contains(
                    "Query execution was interrupted"));
            }
        }
    }

}
 
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:28,代码来源:TimeoutTest.java


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