Mybatis Generator Plus 1.介绍:2.使用方式

程序名称:Mybatis Generator Plus 1.介绍:2.使用方式

授权协议: Apache

操作系统: 跨平台

开发语言: Java

Mybatis Generator Plus 1.介绍:2.使用方式 介绍

@H_404_0@

1.介绍:

@H_404_0@MyBatis generator plus 基于mybatis-generator-core v.1.3.2 扩展,增加如下主要特性:

@H_404_0@1.生成支持Oracle、MysqLsqlserver分页查询代码:

//分页查询demo
OperateLogExample relationshipsExample = new OperateLogExample();
relationshipsExample.setPagination(0L,10L);
List operateLogList = operateLogMapper.selectByExample(relationshipsExample);
@H_404_0@2.生成支持Oracle、MysqLsqlserver批量插入的代码:

//批量插入demo
List operateLogList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
    OperateLog operateLog = new OperateLog.Builder()
        .action("insertBatch_test"+i)
        .build();
    operateLogList.add(operateLog);
}
operateLogMapper.insertBatch(operateLogList);
@H_404[email protected]支持Builder模式创建,示例代码:

User user = new User.Builder()
    .userName("insert_test")
    .creatTime(new Date())
    .updateTime(new Date())
    .build();
@H_404_0@4.支持Oracle使用SEQUENCE实现自增主键:
需要建立表主键对应的SEQUENCE,并且SEQUENCE的名称作出了要求:格式为table_name_SEQUENCE

@H_404_0@5.支持Mapper接口设置数据源schema,可用于分库业务;
demo.mapper.ooc.UserVisitLogMapper.DATA_SOURCE_NAME

@H_404_0@6.针对MysqL分页大偏移量时慢查询优化List selectByBigOffset(DomainExample example);

@H_404_0@7.乐观锁支持int updateByOptimisticLock(Domain record);

2.使用方式

@H_404_0@pom里plugin配置如下:

  org.ihansen.mbp
  mybatis-generator-plus-maven-plugin
  1.4

    true
    true
    tool/mbp/MybatisGeneratorCfg.xml
@H_404_0@供参考的MBP配置文件: MybatisGeneratorCfg.xml
终端运行如下命令,生成自动代码

mvn org.ihansen.mbp:mybatis-generator-plus-maven-plugin:1.4:generate
@H_404_0@包含运行依赖包的可独立执行jar文件mybatis-generator-plus-jar-with-
dependencies.jar

供参考的MBP配置文件: MybatisGeneratorCfg.xml
使用如下命令执行即可生成自动文件

java -jar mybatis-generator-plus-jar-with-dependencies-1.4.jar -configfile MybatisGeneratorCfg.xml -overwrite
@H_404_0@本工具的使用方式和原生的MyBatis generator使用方式一致,兼容原生版本。maven 坐标:

  org.ihansen.mbp
  mybatis-generator-plus
  1.4
  test
@H_404_0@生成文件的示例入口: test/demo.MBPMain

Mybatis Generator Plus 1.介绍:2.使用方式 官网

https://github.com/handosme/mybatis-generator-plus

相关编程语言

BlazeDS 是一个基于服务器的Java 远程控制(remoting...
OVal 是一个可扩展的Java对象数据验证框架,验证的规...
Volta 是一套开发工具,专为开发分布式、实时系统应...
OpenDDS 是一个开源的 C++ 实现的 对象管理组织 OMG...
JADE (Java Agent DEvelopment Framework) 是一个完...
FastMM ,在D2006和2007中已代替了原来的内存管理器。