org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(66)

本文整理了Java中org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.<init>()方法的一些代码示例,展示了Jdbc3KeyGenerator.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jdbc3KeyGenerator.<init>()方法的具体详情如下:
包路径:org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator
类名称:Jdbc3KeyGenerator
方法名:<init>

Jdbc3KeyGenerator.<init>介绍

暂无

代码示例

代码示例来源:origin: baomidou/mybatis-plus

if (tableInfo.getIdType() == IdType.AUTO) {
  keyGenerator = new Jdbc3KeyGenerator();
  keyProperty = tableInfo.getKeyProperty();
  keyColumn = tableInfo.getKeyColumn();

代码示例来源:origin: baomidou/mybatis-plus

@Override
  public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    KeyGenerator keyGenerator = new NoKeyGenerator();
    SqlMethod sqlMethod = SqlMethod.INSERT_ONE;
    String columnScript = SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlColumnMaybeIf(),
      LEFT_BRACKET, RIGHT_BRACKET, null, COMMA);
    String valuesScript = SqlScriptUtils.convertTrim(tableInfo.getAllInsertSqlPropertyMaybeIf(null),
      LEFT_BRACKET, RIGHT_BRACKET, null, COMMA);
    String keyProperty = null;
    String keyColumn = null;
    // 表包含主键处理逻辑,如果不包含主键当普通字段处理
    if (StringUtils.isNotEmpty(tableInfo.getKeyProperty())) {
      if (tableInfo.getIdType() == IdType.AUTO) {
        /** 自增主键 */
        keyGenerator = new Jdbc3KeyGenerator();
        keyProperty = tableInfo.getKeyProperty();
        keyColumn = tableInfo.getKeyColumn();
      } else {
        if (null != tableInfo.getKeySequence()) {
          keyGenerator = TableInfoHelper.genKeyGenerator(tableInfo, builderAssistant, sqlMethod.getMethod(), languageDriver);
          keyProperty = tableInfo.getKeyProperty();
          keyColumn = tableInfo.getKeyColumn();
        }
      }
    }
    String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), columnScript, valuesScript);
    SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
    return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource, keyGenerator, keyProperty, keyColumn);
  }
}

代码示例来源:origin: abel533/Mapper

String IDENTITY = (column.getGenerator() == null || "".equals(column.getGenerator())) ? identity : column.getGenerator();
if ("JDBC".equalsIgnoreCase(IDENTITY)) {
  keyGenerator = new Jdbc3KeyGenerator();
} else {
  SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass);

代码示例来源:origin: abel533/Mapper

String IDENTITY = (column.getGenerator() == null || "".equals(column.getGenerator())) ? identity : column.getGenerator();
if ("JDBC".equalsIgnoreCase(IDENTITY)) {
  keyGenerator = new Jdbc3KeyGenerator();
} else {
  SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass);

代码示例来源:origin: org.apache.ibatis/ibatis-core

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", Object.class, 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();
}

代码示例来源:origin: com.baomidou/mybatis-plus-extension

if (tableInfo.getIdType() == IdType.AUTO) {
  keyGenerator = new Jdbc3KeyGenerator();
  keyProperty = tableInfo.getKeyProperty();
  keyColumn = tableInfo.getKeyColumn();

代码示例来源:origin: org.apache.ibatis/ibatis-core

SqlCommandType sqlCommandType = getSqlCommandType(method);
KeyGenerator keyGenerator = configuration.isUseGeneratedKeys()
  && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
String keyProperty = "id";
if (options != null) {
 statementType = options.statementType();
 resultSetType = options.resultSetType();
 keyGenerator = options.useGeneratedKeys() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
 keyProperty = options.keyProperty();

代码示例来源:origin: vakinge/jeesuite-libs

/**
 * @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);
  }
  
}

代码示例来源:origin: vakinge/jeesuite-libs

/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver,EntityInfo entity) {
  
  
  String msId = entity.getMapperClass().getName() + ".insertList";
  
  // 从参数对象里提取注解信息
  EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
  // 生成sql
  String sql = buildBatchInsertSql(entityMapper);
  
  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);

  
}

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator();
if (IDENTITY.equalsIgnoreCase("JDBC")) {
  keyGenerator = new Jdbc3KeyGenerator();
} else {
  SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass);

代码示例来源:origin: tk.mybatis/mapper-core

String IDENTITY = (column.getGenerator() == null || "".equals(column.getGenerator())) ? identity : column.getGenerator();
if ("JDBC".equalsIgnoreCase(IDENTITY)) {
  keyGenerator = new Jdbc3KeyGenerator();
} else {
  SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass);

代码示例来源:origin: org.apache.ibatis/ibatis-core

keyGenerator = context.getBooleanAttribute("useGeneratedKeys",
  configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))
  ? new Jdbc3KeyGenerator() : new NoKeyGenerator();

代码示例来源:origin: com.github.abel533/mapper

String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator();
if (IDENTITY.equalsIgnoreCase("JDBC")) {
  keyGenerator = new Jdbc3KeyGenerator();
} else {
  SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass);

相关文章