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


Java NoKeyGenerator类代码示例

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


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

示例1: genKeyGenerator

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的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

示例2: Builder

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
public Builder(Configuration configuration, String id, SqlSource sqlSource, SqlCommandType sqlCommandType) {
  mappedStatement.configuration = configuration;
  mappedStatement.id = id;
  mappedStatement.sqlSource = sqlSource;
  mappedStatement.statementType = StatementType.PREPARED;
  mappedStatement.parameterMap = new ParameterMap.Builder(configuration, "defaultParameterMap", null, new ArrayList<ParameterMapping>()).build();
  mappedStatement.resultMaps = new ArrayList<ResultMap>();
  mappedStatement.sqlCommandType = sqlCommandType;
  mappedStatement.keyGenerator = configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
  String logId = id;
  if (configuration.getLogPrefix() != null) {
    logId = configuration.getLogPrefix() + id;
  }
  mappedStatement.statementLog = LogFactory.getLog(logId);
  mappedStatement.lang = configuration.getDefaultScriptingLanuageInstance();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:MappedStatement.java

示例3: genKeyGenerator

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的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

示例4: addSelectMappedStatement

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
/**
   * 查询
   */
  public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource, Class<?> resultType,
                                                  TableInfo table) {
      if (null != table) {
          String resultMap = table.getResultMap();
          if (null != resultMap) {
              /** 返回 resultMap 映射结果集 */
              return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap, null,
                      new NoKeyGenerator(), null, null);
          }
      }

/** 普通查询 */
      return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, null, resultType,
              new NoKeyGenerator(), null, null);
  }
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:19,代码来源:AutoSqlInjector.java

示例5: Builder

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
public Builder(Configuration configuration, String id, SqlSource sqlSource, SqlCommandType sqlCommandType) {
  mappedStatement.configuration = configuration;
  mappedStatement.id = id;
  mappedStatement.sqlSource = sqlSource;
  mappedStatement.statementType = StatementType.PREPARED;
  mappedStatement.parameterMap = new ParameterMap.Builder(configuration, "defaultParameterMap", null, new ArrayList<ParameterMapping>()).build();
  mappedStatement.resultMaps = new ArrayList<ResultMap>();
  mappedStatement.timeout = configuration.getDefaultStatementTimeout();
  mappedStatement.sqlCommandType = sqlCommandType;
  mappedStatement.keyGenerator = configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
  String logId = id;
  if (configuration.getLogPrefix() != null) {
    logId = configuration.getLogPrefix() + id;
  }
  mappedStatement.statementLog = LogFactory.getLog(logId);
  mappedStatement.lang = configuration.getDefaultScriptingLanuageInstance();
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:18,代码来源:MappedStatement.java

示例6: buildDelete

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的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

示例7: buildUpdate

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的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

示例8: buildSelect

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的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

示例9: Builder

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
public Builder(Configuration configuration, String id, SqlSource sqlSource, SqlCommandType sqlCommandType) {
  mappedStatement.configuration = configuration;
  mappedStatement.id = id;
  mappedStatement.sqlSource = sqlSource;
  mappedStatement.statementType = StatementType.PREPARED;
  mappedStatement.parameterMap = new ParameterMap.Builder(configuration, "defaultParameterMap", null, new ArrayList<ParameterMapping>()).build();
  mappedStatement.resultMaps = new ArrayList<ResultMap>();
  mappedStatement.sqlCommandType = sqlCommandType;
  mappedStatement.keyGenerator = configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType) ? Jdbc3KeyGenerator.INSTANCE : NoKeyGenerator.INSTANCE;
  String logId = id;
  if (configuration.getLogPrefix() != null) {
    logId = configuration.getLogPrefix() + id;
  }
  mappedStatement.statementLog = LogFactory.getLog(logId);
  mappedStatement.lang = configuration.getDefaultScriptingLanguageInstance();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:17,代码来源:MappedStatement.java

示例10: addSelectMappedStatement

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource, Class<?> resultType,
                                                  TableInfo table) {
      if (null != table) {
          String resultMap = table.getResultMap();
          if (null != resultMap) {
		/* 返回 resultMap 映射结果集 */
              return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap, null,
                      new NoKeyGenerator(), null, null);
          }
      }

/* 普通查询 */
      return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, null, resultType,
              new NoKeyGenerator(), null, null);
  }
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:16,代码来源:AutoSqlInjector.java

示例11: handleSelectKeyAnnotation

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
    String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
    Class<?> resultTypeClass = selectKeyAnnotation.resultType();
    StatementType statementType = selectKeyAnnotation.statementType();
    String keyProperty = selectKeyAnnotation.keyProperty();
    String keyColumn = selectKeyAnnotation.keyColumn();
    boolean executeBefore = selectKeyAnnotation.before();

    // defaults
    boolean useCache = false;
    KeyGenerator keyGenerator = NoKeyGenerator.INSTANCE;
    Integer fetchSize = null;
    Integer timeout = null;
    boolean flushCache = false;
    String parameterMap = null;
    String resultMap = null;
    ResultSetType resultSetTypeEnum = null;

    SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
    SqlCommandType sqlCommandType = SqlCommandType.SELECT;

    assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
            flushCache, useCache, false,
            keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

    id = assistant.applyCurrentNamespace(id, false);

    MappedStatement keyStatement = configuration.getMappedStatement(id, false);
    SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
    configuration.addKeyGenerator(id, answer);
    return answer;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:33,代码来源:MybatisMapperAnnotationBuilder.java

示例12: build

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {

    String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
    for (String name : names) {
        String msId = entity.getMapperClass().getName() + "." + name;

        // 从参数对象里提取注解信息
        EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
        // 生成sql
        String sql = buildInsertSql(entityMapper, name.endsWith("Selective"));

        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());

        MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.INSERT);

        KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
        statementBuilder.keyGenerator(keyGenerator)//
                .keyProperty(entityMapper.getIdColumn().getProperty())//
                .keyColumn(entityMapper.getIdColumn().getColumn());

        MappedStatement statement = statementBuilder.build();

        configuration.addMappedStatement(statement);
    }

}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:31,代码来源:InsertBuilder.java

示例13: handleSelectKeyAnnotation

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
  String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
  Class<?> resultTypeClass = selectKeyAnnotation.resultType();
  StatementType statementType = selectKeyAnnotation.statementType();
  String keyProperty = selectKeyAnnotation.keyProperty();
  String keyColumn = selectKeyAnnotation.keyColumn();
  boolean executeBefore = selectKeyAnnotation.before();

  // defaults
  boolean useCache = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
      flushCache, useCache, false,
      keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

  id = assistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
  configuration.addKeyGenerator(id, answer);
  return answer;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:33,代码来源:MapperAnnotationBuilder.java

示例14: parseSelectKeyNode

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
private void parseSelectKeyNode(String id, XNode nodeToHandle, Class<?> parameterTypeClass, LanguageDriver langDriver, String databaseId) {
  String resultType = nodeToHandle.getStringAttribute("resultType");
  Class<?> resultTypeClass = resolveClass(resultType);
  StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
  String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
  String keyColumn = nodeToHandle.getStringAttribute("keyColumn");
  boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));

  //defaults
  boolean useCache = false;
  boolean resultOrdered = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = langDriver.createSqlSource(configuration, nodeToHandle, parameterTypeClass);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
      fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
      resultSetTypeEnum, flushCache, useCache, resultOrdered,
      keyGenerator, keyProperty, keyColumn, databaseId, langDriver, null);

  id = builderAssistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  configuration.addKeyGenerator(id, new SelectKeyGenerator(keyStatement, executeBefore));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:33,代码来源:XMLStatementBuilder.java

示例15: build

import org.apache.ibatis.executor.keygen.NoKeyGenerator; //导入依赖的package包/类
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver,EntityInfo entity) {
	
	String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
	for (String name : names) {			
		String msId = entity.getMapperClass().getName() + "." + name;
		
		// 从参数对象里提取注解信息
		EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
		// 生成sql
		String sql = buildInsertSql(entityMapper,name.endsWith("Selective"));
		
		SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
		
		MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,SqlCommandType.INSERT);
		
		KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
		statementBuilder.keyGenerator(keyGenerator)//
                        .keyProperty(entityMapper.getIdColumn().getProperty())//
                        .keyColumn(entityMapper.getIdColumn().getColumn());
        
		MappedStatement statement = statementBuilder.build();
		
		configuration.addMappedStatement(statement);
	}
	
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:31,代码来源:InsertBuilder.java


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