mybatis-plugin

mybatis plugin

License

License

Categories

Categories

MyBatis Data ORM
GroupId

GroupId

cn.weiecho
ArtifactId

ArtifactId

mybatis-plugin
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

mybatis-plugin
mybatis plugin
Project URL

Project URL

https://github.com/weiecho/mybatis-plugin
Source Code Management

Source Code Management

https://github.com/weiecho/mybatis-plugin

Download mybatis-plugin

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
org.mybatis.spring.boot : mybatis-spring-boot-starter Optional jar 2.1.0
org.json : json Optional jar 20190722

Project Modules

There are no modules declared in this project.

mybatis-plugin

根据真实使用场景对mybatis进行的扩展,实现分页、json存储、数组存储、blob存储等支持。

GitHub release Maven Central Repo openjdk License

扩展Mybatis数据类型

1、ArrayTypeHandler 支持数组数据的存储和读取

bean定义格式

private String[] tags;

mapper定义格式

<result property="tags" column="tags" typeHandler="ArrayTypeHandler"/>
2、JsonTypeHandler 支持Json对象数据的存储和读取

bean定义格式

/** 图片 如:[{imageUrl:"/1.jpg"}] **/
private Object imagesUrl;

mapper定义格式

<result property="imagesUrl" column="imagesUrl" typeHandler="JsonTypeHandler"/>
3、BlobTypeHandler 支持Blob数据的存储和读取

bean定义格式

/** 文章内容 **/
private String content;

mapper定义格式

<result property="content" column="content" typeHandler="BlobTypeHandler"/>
4、ListTypeHandler 支持List数据的存储和读取(可以视为Array的升级版)

bean定义格式

private List<String> tags;

mapper定义格式

<result property="tags" column="tags" typeHandler="ListTypeHandler"/>

扩展Mybatis自动执行分页SQL处理

1、MysqlPageInterceptor支持mysql数据的分页
PageInterceptor pageInterceptor = new MysqlPageInterceptor();
sessionFactory.setPlugins(new Interceptor[]{pageInterceptor});
2、OraclePageInterceptor支持oracle数据的分页
PageInterceptor pageInterceptor = new OraclePageInterceptor();
sessionFactory.setPlugins(new Interceptor[]{pageInterceptor});
3、PostgresqlPageInterceptor支持postgresql数据的分页
PageInterceptor pageInterceptor = new PostgresqlPageInterceptor();
sessionFactory.setPlugins(new Interceptor[]{pageInterceptor});

ps:如果分页对应的查询语句中不存在from会throw异常分页查询SQL没有找到[from]关键字,from必须为小写且前后加空格。

cn.weiecho

Wei Echo

Versions

Version
1.0.2
1.0.1