<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Mybatis Generator Plus

          聯(lián)合創(chuàng)作 · 2023-09-30 02:03

          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模式創(chuàng)建,示例代碼:

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

          4.支持Oracle使用SEQUENCE實現(xiàn)自增主鍵:
          需要建立表主鍵對應的SEQUENCE,并且SEQUENCE的名稱作出了要求:格式為table_name_SEQUENCE

          5.支持Mapper接口設置數(shù)據(jù)源schema,可用于分庫業(yè)務;
          demo.mapper.ooc.UserVisitLogMapper.DATA_SOURCE_NAME

          6.針對MySQL下分頁大偏移量時慢查詢優(yōu)化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

          方式二:運行可執(zhí)行jar文件

          包含運行依賴包的可獨立執(zhí)行jar文件:mybatis-generator-plus-jar-with-dependencies.jar
          供參考的MBP配置文件: MybatisGeneratorCfg.xml
          使用如下命令執(zhí)行即可生成自動文件:

          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

          瀏覽 14
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  东京热99 | 色婷婷欧美亚洲激情综合另类在线 | 乱伦小说五月天 | 最新爱爱视频网站 | 欧美成人在线观看免费 |