• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MapperBuilderAssistant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: inject

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
  * 注入单点 crudSql
  */
 public void inject(MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
     this.configuration = builderAssistant.getConfiguration();
     this.builderAssistant = builderAssistant;
     this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
     /*
      * 驼峰设置 PLUS 配置 > 原始配置
*/
     GlobalConfiguration globalCache = this.getGlobalConfig();
     if (!globalCache.isDbColumnUnderline()) {
         globalCache.setDbColumnUnderline(configuration.isMapUnderscoreToCamelCase());
     }
     Class<?> modelClass = extractModelClass(mapperClass);
     if (modelClass != null) {
         TableInfo table = TableInfoHelper.initTableInfo(builderAssistant, modelClass);
         injectSql(builderAssistant, mapperClass, modelClass, table);
     }
 }
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:21,代码来源:AutoSqlInjector.java


示例2: genKeyGenerator

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的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: MapperAnnotationBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
public MapperAnnotationBuilder(Configuration configuration, Class<?> type) {
  String resource = type.getName().replace('.', '/') + ".java (best guess)";
  this.assistant = new MapperBuilderAssistant(configuration, resource);
  this.configuration = configuration;
  this.type = type;

  sqlAnnotationTypes.add(Select.class);
  sqlAnnotationTypes.add(Insert.class);
  sqlAnnotationTypes.add(Update.class);
  sqlAnnotationTypes.add(Delete.class);

  sqlProviderAnnotationTypes.add(SelectProvider.class);
  sqlProviderAnnotationTypes.add(InsertProvider.class);
  sqlProviderAnnotationTypes.add(UpdateProvider.class);
  sqlProviderAnnotationTypes.add(DeleteProvider.class);
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:17,代码来源:MapperAnnotationBuilder.java


示例4: MybatisMapperAnnotationBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
public MybatisMapperAnnotationBuilder(Configuration configuration, Class<?> type) {
    // 执行父类
    super(configuration, type);

    String resource = type.getName().replace('.', '/') + ".java (best guess)";
    this.assistant = new MapperBuilderAssistant(configuration, resource);
    this.configuration = configuration;
    this.type = type;

    sqlAnnotationTypes.add(Select.class);
    sqlAnnotationTypes.add(Insert.class);
    sqlAnnotationTypes.add(Update.class);
    sqlAnnotationTypes.add(Delete.class);

    sqlProviderAnnotationTypes.add(SelectProvider.class);
    sqlProviderAnnotationTypes.add(InsertProvider.class);
    sqlProviderAnnotationTypes.add(UpdateProvider.class);
    sqlProviderAnnotationTypes.add(DeleteProvider.class);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:20,代码来源:MybatisMapperAnnotationBuilder.java


示例5: genKeyGenerator

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


示例6: inject

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
  * 注入单点 crudSql
  */
 @Override
 public void inject(MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
     this.configuration = builderAssistant.getConfiguration();
     this.builderAssistant = builderAssistant;
     this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
     /**
      * 驼峰设置 PLUS 配置 > 原始配置
*/
     GlobalConfiguration globalCache = this.getGlobalConfig();
     if (!globalCache.isDbColumnUnderline()) {
         globalCache.setDbColumnUnderline(configuration.isMapUnderscoreToCamelCase());
     }
     Class<?> modelClass = extractModelClass(mapperClass);
     if (null != modelClass) {
         /**
          * 初始化 SQL 解析
          */
         if (globalCache.isSqlParserCache()) {
             PluginUtils.initSqlParserInfoCache(mapperClass);
         }
         TableInfo table = TableInfoHelper.initTableInfo(builderAssistant, modelClass);
         injectSql(builderAssistant, mapperClass, modelClass, table);
     }
 }
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:28,代码来源:AutoSqlInjector.java


示例7: inspectInject

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
 * CRUD注入后给予标识 注入过后不再注入
 *
 * @param builderAssistant
 * @param mapperClass
 */
public void inspectInject(MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
    String className = mapperClass.toString();
    Set<String> mapperRegistryCache = GlobalConfigUtils.getMapperRegistryCache(builderAssistant.getConfiguration());
    if (!mapperRegistryCache.contains(className)) {
        inject(builderAssistant, mapperClass);
        mapperRegistryCache.add(className);
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:15,代码来源:AutoSqlInjector.java


示例8: MybatisXMLMapperBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
private MybatisXMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
    super(configuration);
    this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
    this.parser = parser;
    this.sqlFragments = sqlFragments;
    this.resource = resource;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:8,代码来源:MybatisXMLMapperBuilder.java


示例9: MybatisMapperAnnotationBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
public MybatisMapperAnnotationBuilder(Configuration configuration, Class<?> type) {
    // TODO 执行父类
    super(configuration, type);
    String resource = type.getName().replace('.', '/') + ".java (best guess)";
    this.assistant = new MapperBuilderAssistant(configuration, resource);
    this.configuration = configuration;
    this.type = type;
    sqlAnnotationTypes.add(Select.class);
    sqlAnnotationTypes.add(Insert.class);
    sqlAnnotationTypes.add(Update.class);
    sqlAnnotationTypes.add(Delete.class);
    sqlProviderAnnotationTypes.add(SelectProvider.class);
    sqlProviderAnnotationTypes.add(InsertProvider.class);
    sqlProviderAnnotationTypes.add(UpdateProvider.class);
    sqlProviderAnnotationTypes.add(DeleteProvider.class);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:17,代码来源:MybatisMapperAnnotationBuilder.java


示例10: inject

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
@Override
public void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass,
                   Class<?> modelClass, TableInfo table) {
    /* 添加一个自定义方法 */
    deleteAllUser(mapperClass, modelClass, table);
    // 测试 com.baomidou.mybatisplus.test.mysql.MetaObjectHandlerTest
    deleteLogicById(mapperClass, modelClass, table);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:9,代码来源:MySqlInjector.java


示例11: XMLMapperBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
private XMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
  super(configuration);
  this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
  this.parser = parser;
  this.sqlFragments = sqlFragments;
  this.resource = resource;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:XMLMapperBuilder.java


示例12: XMLMapperBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
private XMLMapperBuilder(XPathParser parser, Configuration configuration,
		String resource, Map<String, XNode> sqlFragments) {
	super(configuration);
	this.builderAssistant = new MapperBuilderAssistant(configuration,
			resource);
	this.parser = parser;
	this.sqlFragments = sqlFragments;
	this.resource = resource;
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:10,代码来源:XMLMapperBuilder.java


示例13: inspectInject

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
 * <p>
 * CRUD 注入后给予标识 注入过后不再注入
 * </p>
 *
 * @param builderAssistant
 * @param mapperClass
 */
@Override
public void inspectInject(MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
    String className = mapperClass.toString();
    Set<String> mapperRegistryCache = GlobalConfigUtils.getMapperRegistryCache(builderAssistant.getConfiguration());
    if (!mapperRegistryCache.contains(className)) {
        inject(builderAssistant, mapperClass);
        mapperRegistryCache.add(className);
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:18,代码来源:AutoSqlInjector.java


示例14: injectSql

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
 * <p>
 * 注入SQL
 * </p>
 *
 * @param builderAssistant
 * @param mapperClass
 * @param modelClass
 * @param table
 */
protected void injectSql(MapperBuilderAssistant builderAssistant, Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
    /**
     * #148 表信息包含主键,注入主键相关方法
     */
    if (StringUtils.isNotEmpty(table.getKeyProperty())) {
        /* 删除 */
        this.injectDeleteByIdSql(false, mapperClass, modelClass, table);
        this.injectDeleteByIdSql(true, mapperClass, modelClass, table);
        /* 修改 */
        this.injectUpdateByIdSql(true, mapperClass, modelClass, table);
        this.injectUpdateByIdSql(false, mapperClass, modelClass, table);
        /* 查询 */
        this.injectSelectByIdSql(false, mapperClass, modelClass, table);
        this.injectSelectByIdSql(true, mapperClass, modelClass, table);
    } else {
        // 表不包含主键时 给予警告
        logger.warn(String.format("%s ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method.",
                modelClass.toString()));
    }
    /**
     * 正常注入无需主键方法
     */
    /* 插入 */
    this.injectInsertOneSql(true, mapperClass, modelClass, table);
    this.injectInsertOneSql(false, mapperClass, modelClass, table);
    /* 删除 */
    this.injectDeleteSql(mapperClass, modelClass, table);
    /* 修改 */
    this.injectUpdateSql(mapperClass, modelClass, table);
    /* 查询 */
    this.injectSelectOneSql(mapperClass, modelClass, table);
    this.injectSelectCountSql(mapperClass, modelClass, table);
    this.injectSelectListSql(SqlMethod.SELECT_LIST, mapperClass, modelClass, table);
    this.injectSelectListSql(SqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
    this.injectSelectMapsSql(SqlMethod.SELECT_MAPS, mapperClass, modelClass, table);
    this.injectSelectMapsSql(SqlMethod.SELECT_MAPS_PAGE, mapperClass, modelClass, table);
    this.injectSelectObjsSql(SqlMethod.SELECT_OBJS, mapperClass, modelClass, table);
    /* 自定义方法 */
    this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:51,代码来源:AutoSqlInjector.java


示例15: XMLIncludeTransformer

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
public XMLIncludeTransformer(Configuration configuration, MapperBuilderAssistant builderAssistant) {
  this.configuration = configuration;
  this.builderAssistant = builderAssistant;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:5,代码来源:XMLIncludeTransformer.java


示例16: XMLStatementBuilder

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
public XMLStatementBuilder(Configuration configuration, MapperBuilderAssistant builderAssistant, XNode context) {
  this(configuration, builderAssistant, context, null);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:4,代码来源:XMLStatementBuilder.java


示例17: injectSql

import org.apache.ibatis.builder.MapperBuilderAssistant; //导入依赖的package包/类
/**
 * <p>
 * 注入SQL
 * </p>
 *
 * @param builderAssistant
 * @param mapperClass
 * @param modelClass
 * @param table
 */
protected void injectSql(MapperBuilderAssistant builderAssistant, Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
    /**
     * #148 表信息包含主键,注入主键相关方法
     */
    if (StringUtils.isNotEmpty(table.getKeyProperty())) {
        /** 删除 */
        this.injectDeleteByIdSql(false, mapperClass, modelClass, table);
        this.injectDeleteByIdSql(true, mapperClass, modelClass, table);
        /** 修改 */
        this.injectUpdateByIdSql(true, mapperClass, modelClass, table);
        this.injectUpdateByIdSql(false, mapperClass, modelClass, table);
        /** 查询 */
        this.injectSelectByIdSql(false, mapperClass, modelClass, table);
        this.injectSelectByIdSql(true, mapperClass, modelClass, table);
    } else {
        // 表不包含主键时 给予警告
        logger.warn(String.format("%s ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method.",
                modelClass.toString()));
    }
    /**
     * 正常注入无需主键方法
     */
    /** 插入 */
    this.injectInsertOneSql(true, mapperClass, modelClass, table);
    this.injectInsertOneSql(false, mapperClass, modelClass, table);
    /** 删除 */
    this.injectDeleteSql(mapperClass, modelClass, table);
    this.injectDeleteByMapSql(mapperClass, table);
    /** 修改 */
    this.injectUpdateSql(mapperClass, modelClass, table);
    /** 查询 */
    this.injectSelectByMapSql(mapperClass, modelClass, table);
    this.injectSelectOneSql(mapperClass, modelClass, table);
    this.injectSelectCountSql(mapperClass, modelClass, table);
    this.injectSelectListSql(SqlMethod.SELECT_LIST, mapperClass, modelClass, table);
    this.injectSelectListSql(SqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
    this.injectSelectMapsSql(SqlMethod.SELECT_MAPS, mapperClass, modelClass, table);
    this.injectSelectMapsSql(SqlMethod.SELECT_MAPS_PAGE, mapperClass, modelClass, table);
    this.injectSelectObjsSql(SqlMethod.SELECT_OBJS, mapperClass, modelClass, table);
    /** 自定义方法 */
    this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:53,代码来源:AutoSqlInjector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnderChest类代码示例发布时间:2022-05-22
下一篇:
Java PhotosInterface类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap