Mybatis Generator Plus

码农软件 · 软件分类 · ORM/持久层框架 · 2019-09-23 06:28:48

软件介绍

1.介绍:

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

1.生成支持Oracle、Mysql、Sqlserver分页查询的代码:

//分页查询demo
OperateLogExample relationshipsExample = new OperateLogExample();
relationshipsExample.setPagination(0L,10L);
List operateLogList = operateLogMapper.selectByExample(relationshipsExample);

2.生成支持Oracle、Mysql、Sqlserver批量插入的代码:

//批量插入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);

3.Model类支持Builder模式创建,示例代码:

User user = new User.Builder()
    .userName("insert_test")
    .creatTime(new Date())
    .updateTime(new Date())
    .build();

4.支持Oracle使用SEQUENCE实现自增主键:
需要建立表主键对应的SEQUENCE,并且SEQUENCE的名称作出了要求:格式为table_name_SEQUENCE

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

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

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

 

2.使用方式

方式一: 配置maven插件生成代码【推荐】

pom里plugin配置如下:


  org.ihansen.mbp
  mybatis-generator-plus-maven-plugin
  1.4
  
    true
    true
    tool/mbp/MybatisGeneratorCfg.xml
  

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

mvn org.ihansen.mbp:mybatis-generator-plus-maven-plugin:1.4:generate

方式二:运行可执行jar文件

包含运行依赖包的可独立执行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

方式三:main方法运行

本工具的使用方式和原生的MyBatis generator使用方式一致,兼容原生版本。maven 坐标:


  org.ihansen.mbp
  mybatis-generator-plus
  1.4
  test

生成文件的示例入口: test/demo.MBPMain

本文地址:https://codercto.com/soft/d/15198.html

测试驱动开发

测试驱动开发

Kent Beck / 孙平平、张小龙 / 中国电力出版社 / 2004-4-1 / 28.00元

《测试驱动开发》(中文版)设想把编程看成是转动曲柄从井里提一桶水上来的过程。如果水桶比较小,那么仅需一个能自由转动的曲柄就可以了。如果水桶比较大而且装满水,那么还没等水桶全部被提上来你就会很累了。你需要一个防倒转的装置,以保证每转一次可以休息一会儿。水桶越重,防倒转的棘齿相距越近。测试驱动开发中的测试程序就是防倒转装置上的棘齿。一旦我们的某个测试程序能工作了,你就知道,它从现在开始并且以后永远都可......一起来看看 《测试驱动开发》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

MD5 加密
MD5 加密

MD5 加密工具