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


Java StatementType类代码示例

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


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

示例1: prepareSelectAuthorViaOutParams

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
public static MappedStatement prepareSelectAuthorViaOutParams(final Configuration config) {
  final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
  MappedStatement ms = new MappedStatement.Builder(config, "selectAuthorViaOutParams", new StaticSqlSource(config, "{call selectAuthorViaOutParams(?,?,?,?,?)}"), SqlCommandType.SELECT)
      .statementType(StatementType.CALLABLE)
      .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
          new ArrayList<ParameterMapping>() {
            {
              add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
              add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
            }
          }).build())
      .resultMaps(new ArrayList<ResultMap>())
      .cache(authorCache).build();
  return ms;
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:19,代码来源:ExecutorTestHelper.java

示例2: addMappedStatement

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
                                            SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
                                            KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
      String statementName = mapperClass.getName() + "." + id;
      if (configuration.hasStatement(statementName)) {
          System.err.println("{" + statementName
                  + "} Has been loaded by XML or SqlProvider, ignoring the injection of the SQL.");
          return null;
      }
/* 缓存逻辑处理 */
      boolean isSelect = false;
      if (sqlCommandType == SqlCommandType.SELECT) {
          isSelect = true;
      }
      return builderAssistant.addMappedStatement(id, sqlSource, StatementType.PREPARED, sqlCommandType, null, null, null,
              parameterClass, resultMap, resultType, null, !isSelect, isSelect, false, keyGenerator, keyProperty, keyColumn,
              configuration.getDatabaseId(), languageDriver, null);
  }
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:19,代码来源:AutoSqlInjector.java

示例3: genKeyGenerator

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
/**
 * <p>
 * 自定义 KEY 生成器
 * </p>
 */
public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
                                           String baseStatementId, LanguageDriver languageDriver) {
    Incrementer incrementer = GlobalConfigUtils.getIncrementer(builderAssistant.getConfiguration());
    if (null == incrementer) {
        throw new MybatisPlusException("Error: not configure Incrementer implementation class.");
    }
    String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
    Class<?> resultTypeClass = tableInfo.getKeySequence().idClazz();
    StatementType statementType = StatementType.PREPARED;
    String keyProperty = tableInfo.getKeyProperty();
    String keyColumn = tableInfo.getKeyColumn();
    SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(),
            incrementer.getSequenceQuery(tableInfo.getKeySequence().value()), null);
    builderAssistant.addMappedStatement(id, sqlSource, statementType, SqlCommandType.SELECT, null, null, null,
            null, null, resultTypeClass, null, false, false, false,
            new NoKeyGenerator(), keyProperty, keyColumn, null, languageDriver, null);
    id = builderAssistant.applyCurrentNamespace(id, false);
    MappedStatement keyStatement = builderAssistant.getConfiguration().getMappedStatement(id, false);
    SelectKeyGenerator keyGenerator = new SelectKeyGenerator(keyStatement, true);
    builderAssistant.getConfiguration().addKeyGenerator(id, keyGenerator);
    return keyGenerator;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:28,代码来源:TableInfoHelper.java

示例4: handleLocallyCachedOutputParameters

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private void handleLocallyCachedOutputParameters(MappedStatement ms, CacheKey key, Object parameter, BoundSql boundSql) {
  if (ms.getStatementType() == StatementType.CALLABLE) {
    final Object cachedParameter = localOutputParameterCache.getObject(key);
    if (cachedParameter != null && parameter != null) {
      final MetaObject metaCachedParameter = configuration.newMetaObject(cachedParameter);
      final MetaObject metaParameter = configuration.newMetaObject(parameter);
      for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
        if (parameterMapping.getMode() != ParameterMode.IN) {
          final String parameterName = parameterMapping.getProperty();
          final Object cachedValue = metaCachedParameter.getValue(parameterName);
          metaParameter.setValue(parameterName, cachedValue);
        }
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:BaseExecutor.java

示例5: mappedStatementWithOptions

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
@Test
public void mappedStatementWithOptions() throws Exception {
  Configuration configuration = new Configuration();
  String resource = "org/apache/ibatis/builder/AuthorMapper.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
  builder.parse();

  MappedStatement mappedStatement = configuration.getMappedStatement("selectWithOptions");
  assertThat(mappedStatement.getFetchSize(), is(200));
  assertThat(mappedStatement.getTimeout(), is(10));
  assertThat(mappedStatement.getStatementType(), is(StatementType.PREPARED));
  assertThat(mappedStatement.getResultSetType(), is(ResultSetType.SCROLL_SENSITIVE));
  assertThat(mappedStatement.isFlushCacheRequired(), is(false));
  assertThat(mappedStatement.isUseCache(), is(false));

}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:XmlMapperBuilderTest.java

示例6: createSelectAuthorWithIDof99MappedStatement

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
public static MappedStatement createSelectAuthorWithIDof99MappedStatement(final Configuration config) {
  final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
  MappedStatement ms = new MappedStatement.Builder(config, "selectAuthor", new StaticSqlSource(config,"SELECT * FROM author WHERE id = 99"), SqlCommandType.SELECT)
      .statementType(StatementType.STATEMENT)
      .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class, new ArrayList<ParameterMapping>()).build())
      .resultMaps(new ArrayList<ResultMap>() {
        {
          add(new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList<ResultMapping>() {
            {
              add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
              add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
              add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
              add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
              add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
            }
          }).build());
        }
      }).build();
  return ms;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:ExecutorTestHelper.java

示例7: queryFromDatabase

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private <E> List<E> queryFromDatabase(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql) throws SQLException {
  List<E> list;
  // 源码解析: 填充本地缓存
  localCache.putObject(key, EXECUTION_PLACEHOLDER);
  try {
    // 源码解析: 查询结果集
    list = doQuery(ms, parameter, rowBounds, resultHandler, boundSql);
  } finally {
    // 源码解析: 清除本地缓存
    localCache.removeObject(key);
  }
  // 源码解析: 查询结果集放入本地缓存
  localCache.putObject(key, list);
  if (ms.getStatementType() == StatementType.CALLABLE) {
    localOutputParameterCache.putObject(key, parameter);
  }
  return list;
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:19,代码来源:BaseExecutor.java

示例8: genKeyGenerator

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
/**
 * <p>
 * 自定义 KEY 生成器
 * </p>
 */
public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
                                           String baseStatementId, LanguageDriver languageDriver) {
    IKeyGenerator keyGenerator = GlobalConfigUtils.getKeyGenerator(builderAssistant.getConfiguration());
    if (null == keyGenerator) {
        throw new IllegalArgumentException("not configure IKeyGenerator implementation class.");
    }
    String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
    Class<?> resultTypeClass = tableInfo.getKeySequence().clazz();
    StatementType statementType = StatementType.PREPARED;
    String keyProperty = tableInfo.getKeyProperty();
    String keyColumn = tableInfo.getKeyColumn();
    SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(),
            keyGenerator.executeSql(tableInfo.getKeySequence().value()), null);
    builderAssistant.addMappedStatement(id, sqlSource, statementType, SqlCommandType.SELECT, null, null, null,
            null, null, resultTypeClass, null, false, false, false,
            new NoKeyGenerator(), keyProperty, keyColumn, null, languageDriver, null);
    id = builderAssistant.applyCurrentNamespace(id, false);
    MappedStatement keyStatement = builderAssistant.getConfiguration().getMappedStatement(id, false);
    SelectKeyGenerator selectKeyGenerator = new SelectKeyGenerator(keyStatement, true);
    builderAssistant.getConfiguration().addKeyGenerator(id, selectKeyGenerator);
    return selectKeyGenerator;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:28,代码来源:TableInfoHelper.java

示例9: addMappedStatement

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
                                            SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
                                            KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
      String statementName = mapperClass.getName() + "." + id;
      if (hasMappedStatement(statementName)) {
          System.err.println("{" + statementName
                  + "} Has been loaded by XML or SqlProvider, ignoring the injection of the SQL.");
          return null;
      }
/** 缓存逻辑处理 */
      boolean isSelect = false;
      if (sqlCommandType == SqlCommandType.SELECT) {
          isSelect = true;
      }
      return builderAssistant.addMappedStatement(id, sqlSource, StatementType.PREPARED, sqlCommandType, null, null, null,
              parameterClass, resultMap, resultType, null, !isSelect, isSelect, false, keyGenerator, keyProperty, keyColumn,
              configuration.getDatabaseId(), languageDriver, null);
  }
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:19,代码来源:AutoSqlInjector.java

示例10: handleLocallyCachedOutputParameters

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private void handleLocallyCachedOutputParameters(MappedStatement ms, CacheKey key, Object parameter, BoundSql boundSql) {
  //处理存储过程的OUT参数
  if (ms.getStatementType() == StatementType.CALLABLE) {
    final Object cachedParameter = localOutputParameterCache.getObject(key);
    if (cachedParameter != null && parameter != null) {
      final MetaObject metaCachedParameter = configuration.newMetaObject(cachedParameter);
      final MetaObject metaParameter = configuration.newMetaObject(parameter);
      for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
        if (parameterMapping.getMode() != ParameterMode.IN) {
          final String parameterName = parameterMapping.getProperty();
          final Object cachedValue = metaCachedParameter.getValue(parameterName);
          metaParameter.setValue(parameterName, cachedValue);
        }
      }
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:18,代码来源:BaseExecutor.java

示例11: queryFromDatabase

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private <E> List<E> queryFromDatabase(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql) throws SQLException {
  List<E> list;
  //先向缓存中放入占位符???
  localCache.putObject(key, EXECUTION_PLACEHOLDER);
  try {
    list = doQuery(ms, parameter, rowBounds, resultHandler, boundSql);
  } finally {
    //最后删除占位符
    localCache.removeObject(key);
  }
  //加入缓存
  localCache.putObject(key, list);
  //如果是存储过程,OUT参数也加入缓存
  if (ms.getStatementType() == StatementType.CALLABLE) {
    localOutputParameterCache.putObject(key, parameter);
  }
  return list;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:19,代码来源:BaseExecutor.java

示例12: bindingLog

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
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));
            }
        }
    }
 
开发者ID:naver,项目名称:pinpoint,代码行数:18,代码来源:BindingLogPlugin32.java

示例13: buildDelete

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private void buildDelete(String statementId){
	Integer timeout = null;
	Class<?> parameterType = entityClass;
	
	//~~~~~~~~~~~~~~~~~~~~~~~
	boolean flushCache = true;
	boolean useCache = false;
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	SqlNode sqlNode = new TextSqlNode("DELETE FROM " + tableName + " WHERE " + getIdColumnName() + " = #{" + getIdFieldName() + "} " + getVersionSQL());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, sqlNode);
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.DELETE, null, timeout, null, parameterType, null, null, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:19,代码来源:GenericStatementBuilder.java

示例14: buildUpdate

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private void buildUpdate(String statementId){
	Integer timeout = null;
	Class<?> parameterType = entityClass;
	
	//~~~~~~~~~~~~~
	boolean flushCache = true;
	boolean useCache = false;
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	List<SqlNode> contents = new ArrayList<SqlNode>();
	contents.add(this.getUpdateSql());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, new MixedSqlNode(contents));
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.UPDATE, null, timeout, null, parameterType, null, null, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:20,代码来源:GenericStatementBuilder.java

示例15: buildSelect

import org.apache.ibatis.mapping.StatementType; //导入依赖的package包/类
private void buildSelect(String statementId){
	Integer fetchSize  = null;
	Integer timeout = entity.timeout() == -1 ? null : entity.timeout();
	Class<?> resultType = entityClass;
	
	//~~~~~~~~~~~~~~~~~
	boolean flushCache = entity.flushCache();
	boolean useCache = entity.useCache();
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	List<SqlNode> contents = new ArrayList<SqlNode>();
	contents.add(this.getGetSql());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, new MixedSqlNode(contents));
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.SELECT, fetchSize, timeout, null, null, null, resultType, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:21,代码来源:GenericStatementBuilder.java


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