Example usage for org.apache.ibatis.builder MapperBuilderAssistant applyCurrentNamespace

List of usage examples for org.apache.ibatis.builder MapperBuilderAssistant applyCurrentNamespace

Introduction

In this page you can find the example usage for org.apache.ibatis.builder MapperBuilderAssistant applyCurrentNamespace.

Prototype

public String applyCurrentNamespace(String base, boolean isReference) 

Source Link

Usage

From source file:com.baomidou.mybatisplus.toolkit.TableInfoHelper.java

License:Apache License

public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
        String baseStatementId, LanguageDriver languageDriver) {
    DBType dbType = GlobalConfiguration.getDbType(builderAssistant.getConfiguration());
    if (dbType != DBType.ORACLE)
        throw new IllegalArgumentException("??Oracle?");
    String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
    Class<?> resultTypeClass = tableInfo.getKeySequence().idClazz();
    Class<?> parameterTypeClass = null;
    StatementType statementType = StatementType.PREPARED;
    String keyProperty = tableInfo.getKeyProperty();
    String keyColumn = tableInfo.getKeyColumn();
    boolean executeBefore = true;
    boolean useCache = false;
    KeyGenerator keyGenerator = new NoKeyGenerator();
    Integer fetchSize = null;/*from   w w w .  j ava  2  s  . c  om*/
    Integer timeout = null;
    boolean flushCache = false;
    String parameterMap = null;
    String resultMap = null;
    ResultSetType resultSetTypeEnum = null;
    //??ORACLE????
    String sql = "select " + tableInfo.getKeySequence().value() + ".nextval from dual";
    SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(), sql.trim(), null);
    SqlCommandType sqlCommandType = SqlCommandType.SELECT;
    builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout,
            parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum, flushCache,
            useCache, false, keyGenerator, keyProperty, keyColumn, null, languageDriver, null);
    id = builderAssistant.applyCurrentNamespace(id, false);
    MappedStatement keyStatement = builderAssistant.getConfiguration().getMappedStatement(id, false);
    SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
    builderAssistant.getConfiguration().addKeyGenerator(id, answer);
    return answer;
}

From source file:com.sinotopia.mybatis.plus.toolkit.TableInfoHelper.java

License:Apache License

/**
 * <p>/*from  w w  w. j  ava2s .com*/
 *  KEY ?
 * </p>
 */
public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
        String baseStatementId, LanguageDriver languageDriver) {
    IKeyGenerator keyGenerator = GlobalConfiguration.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().idClazz();
    StatementType statementType = StatementType.PREPARED;
    String keyProperty = tableInfo.getKeyProperty();
    String keyColumn = tableInfo.getKeyColumn();
    SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(),
            keyGenerator.executeSql(tableInfo), 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 answer = new SelectKeyGenerator(keyStatement, true);
    builderAssistant.getConfiguration().addKeyGenerator(id, answer);
    return answer;
}