mybatis-generator-ext

extension for mybatis-generator

License

License

Categories

Categories

MyBatis Data ORM
GroupId

GroupId

me.aifaq
ArtifactId

ArtifactId

mybatis-generator-ext
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

mybatis-generator-ext
extension for mybatis-generator
Project URL

Project URL

https://github.com/aifaq/mybatis-generator-ext
Source Code Management

Source Code Management

https://github.com/aifaq/mybatis-generator-ext

Download mybatis-generator-ext

How to add to project

<!-- https://jarcasting.com/artifacts/me.aifaq/mybatis-generator-ext/ -->
<dependency>
    <groupId>me.aifaq</groupId>
    <artifactId>mybatis-generator-ext</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/me.aifaq/mybatis-generator-ext/
implementation 'me.aifaq:mybatis-generator-ext:1.0'
// https://jarcasting.com/artifacts/me.aifaq/mybatis-generator-ext/
implementation ("me.aifaq:mybatis-generator-ext:1.0")
'me.aifaq:mybatis-generator-ext:jar:1.0'
<dependency org="me.aifaq" name="mybatis-generator-ext" rev="1.0">
  <artifact name="mybatis-generator-ext" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.aifaq', module='mybatis-generator-ext', version='1.0')
)
libraryDependencies += "me.aifaq" % "mybatis-generator-ext" % "1.0"
[me.aifaq/mybatis-generator-ext "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.mybatis.generator : mybatis-generator-core jar 1.3.7

provided (3)

Group / Artifact Type Version
mysql : mysql-connector-java jar 5.1.47
org.springframework.data : spring-data-commons jar 2.0.9.RELEASE
org.mybatis : mybatis jar 3.4.6

Project Modules

There are no modules declared in this project.

mybatis-generator-ext

<dependency>
	<groupId>me.aifaq</groupId>
	<artifactId>mybatis-generator-ext</artifactId>
	<version>VERSION</version>
</dependency>

扩展插件

MapperPlugin

<plugin type="me.aifaq.mybatis.generator.plugins.MapperPlugin" />

在生成的Mapper类上添加注解 @org.apache.ibatis.annotations.Mapper

ForceSkipMergeSqlMapPlugin

<plugin type="me.aifaq.mybatis.generator.plugins.ForceSkipMergeSqlMapPlugin" />

强制sql mapper.xml 不做merge操作

SpringDataPagePlugin

<plugin type="me.aifaq.mybatis.generator.plugins.SpringDataPagePlugin" />

使用 spring-data-commons 中的分页Bean实现分页查询。

原理:

在生成的 **Example 类中添加属性:

  protected org.springframework.data.domain.Pageable page;

同时在生成的 sql mapper.xml 中添加该属性的逻辑判断,如下:

  <sql id="SpringDataPageSql">
    <if test="page != null">
      <if test="page.sort != null">
        ORDER BY
        <foreach collection="page.sort" item="order" index="index" open="" separator="," close="">
          ${order.property,jdbcType=VARCHAR} ${order.direction,jdbcType=VARCHAR}
        </foreach>
      </if>
      LIMIT #{page.offset,jdbcType=INTEGER},#{page.pageSize,jdbcType=INTEGER}
    </if>
  </sql>

Versions

Version
1.0
0.1