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


Java LanguageDriver类代码示例

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


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

示例1: getSqlSourceFromAnnotations

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
    try {
        Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
        Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
        if (sqlAnnotationType != null) {
            if (sqlProviderAnnotationType != null) {
                throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
            }
            Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
            final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
            return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
        } else if (sqlProviderAnnotationType != null) {
            Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
            return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
        }
        return null;
    } catch (Exception e) {
        throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:21,代码来源:MybatisMapperAnnotationBuilder.java

示例2: genKeyGenerator

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

示例3: build

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver,
                         EntityInfo entity) {
    String[] names = GeneralSqlGenerator.methodDefines.updateName().split(",");
    for (String name : names) {
        String msId = entity.getMapperClass().getName() + "." + name;

        EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());

        String sql = buildUpdateSql(entityMapper, name.endsWith("Selective"));

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

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

        MappedStatement statement = statementBuilder.build();

        configuration.addMappedStatement(statement);
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:26,代码来源:UpdateBuilder.java

示例4: build

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
    String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.deleteName();

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

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

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

    MappedStatement statement = statementBuilder.build();
    configuration.addMappedStatement(statement);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:20,代码来源:DeleteBuilder.java

示例5: getSqlSourceFromAnnotations

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
  try {
    Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
    Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
    if (sqlAnnotationType != null) {
      if (sqlProviderAnnotationType != null) {
        throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
      }
      Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
      final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
      return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
    } else if (sqlProviderAnnotationType != null) {
      Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
      return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
    }
    return null;
  } catch (Exception e) {
    throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:MapperAnnotationBuilder.java

示例6: getSqlSourceFromAnnotations

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
    try {
        Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
        Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
        if (sqlAnnotationType != null) {
            if (sqlProviderAnnotationType != null) {
                throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
            }
            Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
            final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
            return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
        } else if (sqlProviderAnnotationType != null) {
            Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
            return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
        }
        return null;
    } catch (Exception e) {
        throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:21,代码来源:MybatisMapperAnnotationBuilder.java

示例7: genKeyGenerator

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

示例8: build

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration,LanguageDriver languageDriver, EntityInfo entity) {
	String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.deleteName();

	// 从参数对象里提取注解信息
	EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
	// 生成sql
	String sql = buildDeleteSql(entityMapper);
	
	SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
	
	MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,SqlCommandType.DELETE);

	MappedStatement statement = statementBuilder.build();
	configuration.addMappedStatement(statement);
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:20,代码来源:DeleteBuilder.java

示例9: getLanguageDriver

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private LanguageDriver getLanguageDriver(String lang) {
	Class<?> langClass;
	Configuration configuration = sqlSessionTemplate.getConfiguration();
	if (lang == null) {
		langClass = configuration.getLanguageRegistry()
				.getDefaultDriverClass();
	} else {
		langClass = configuration.getTypeAliasRegistry().resolveAlias(lang);
		configuration.getLanguageRegistry().register(langClass);
	}
	if (langClass == null) {
		langClass = configuration.getLanguageRegistry()
				.getDefaultDriverClass();
	}
	return configuration.getLanguageRegistry().getDriver(langClass);
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:17,代码来源:MybatisJdbcProcessor.java

示例10: setUp

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.metricRegistry = new MetricRegistry();
    this.interceptor = new InstrumentingInterceptor( metricRegistry );
    this.fakeExecutor = mock( Executor.class );
    this.fakeStatement = new MappedStatement.Builder( mock( Configuration.class ),
                                                      "statement id",
                                                      mock( SqlSource.class ),
                                                      SqlCommandType.SELECT ).lang( mock( LanguageDriver.class ) )
                                                                             .build();
    this.invocation = new Invocation( fakeExecutor,
                                      Executor.class.getDeclaredMethod( "query",
                                                                        MappedStatement.class,
                                                                        Object.class,
                                                                        RowBounds.class,
                                                                        ResultHandler.class,
                                                                        CacheKey.class,
                                                                        BoundSql.class ),
                                      new Object[] { fakeStatement, null, null, null, null, null } );
}
 
开发者ID:tguzik,项目名称:mybatis-metrics,代码行数:21,代码来源:InstrumentingInterceptorTest.java

示例11: getSqlSourceFromAnnotations

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
  try {
    Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
    Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
    if (sqlAnnotationType != null) {
      if (sqlProviderAnnotationType != null) {
        throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
      }
      Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
      final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
      return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
    } else if (sqlProviderAnnotationType != null) {
      Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
      return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
    }
    return null;
  } catch (Exception e) {
    throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:21,代码来源:MapperAnnotationBuilder.java

示例12: getLanguageDriver

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private LanguageDriver getLanguageDriver(Method method) {
    Lang lang = method.getAnnotation(Lang.class);
    Class<?> langClass = null;
    if (lang != null) {
        langClass = lang.value();
    }
    return assistant.getLanguageDriver(langClass);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:9,代码来源:MybatisMapperAnnotationBuilder.java

示例13: buildSqlSourceFromStrings

import org.apache.ibatis.scripting.LanguageDriver; //导入依赖的package包/类
private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
    final StringBuilder sql = new StringBuilder();
    for (String fragment : strings) {
        sql.append(fragment);
        sql.append(" ");
    }
    return languageDriver.createSqlSource(configuration, sql.toString().trim(), parameterTypeClass);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:9,代码来源:MybatisMapperAnnotationBuilder.java

示例14: handleSelectKeyAnnotation

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

示例15: build

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


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