9 Star 21 Fork 1

TRY_To_TRY / mybatis-generator-xplugin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

mybatis-generator-xplugin

收集了很多mybatis-generator的插件,都是自己项目中用到的,为了方面使用,会上传到中心maven库,凡是用了其他人的插件,都会说明,如有冒犯,请告知,立马删除。邮箱:tryer@vip.qq.com

当初就是因为引用不方便,所以建了这个工程,集合了很多好用的插件,当前版本0.0.1

<dependency>
    <groupId>com.trytotry</groupId>
    <artifactId>mybatis-generator-xplugin</artifactId>
    <version>0.0.1</version>
</dependency>

OverIsMergeablePlugin

在生产xml文件的时候,默认会追加方法,而不会覆盖重写,找了很多方法,终于找到这个有用的,谢谢作者
原作者地址:https://my.oschina.net/u/137785/blog/736372
引入插件

<plugin type="com.trytotry.mybatis.generator.plugin.OverIsMergeablePlugin"/>

SelectByColumnPlugin

自己写的方法,会生成selectByxxx的方法,方便查询 引入插件

<plugin type="com.trytotry.mybatis.generator.plugin.SelectByColumnPlugin"/>

config中配置

<table tableName="test">
    <property name="selectBy" value="name"/>
</table>

则对应TestMapper中生产方法

List<Test> selectByName(String name);

ModelEqualsPlugin

自己写的插件,在model中生成equals的重载方法,方便判断 引入插件:

<plugin type="com.trytotry.mybatis.generator.plugin.ModelEqualsPlugin"/>

config中配置,此时,equals将会判断字段id和name是否相等,相等则return true

<table tableName="test">
    <property name="equalsValue" value="id,name"/>
</table>

MySqlUpsertPlugin

生成upsert方法 原作者地址:https://github.com/beihaifeiwu/dolphin 引入插件(保留原作者包名)

<plugin type="com.freetmp.mbg.plugin.upsert.MySqlUpsertPlugin"/>

Java Sample

Test test = new Test().setId(2).setName("123").setPrice(123d);
mapper.upsert(test);

对应生产sql

INSERT INTO test (id, NAME, price)
    VALUES (2, '123', 123) 
ON DUPLICATE KEY 
    UPDATE id = 1,
	NAME = '123',
	price = 123

MinMaxPlugin

在mapper中增加min和max方法 原作者地址:https://github.com/oceanc/mybatis3-generator-plugins 引入插件(保留原作者包名)

<plugin type="com.github.oceanc.mybatis3.generator.plugin.MinMaxPlugin"/>

config中配置

<table tableName="test">
    <property name="minColumns" value="id,price"/>
    <property name="maxColumns" value="id,price"/>
</table>

则对应生产Java代码

mapper.maxIdByExample(example);
mapper.minIdByExample(example);
mapper.maxPriceByExample(example);
mapper.minPriceByExample(example);

SumSelectivePlugin

sum插件 原作者地址:https://github.com/oceanc/mybatis3-generator-plugins 引入插件(保留原作者包名)

<plugin type="com.github.oceanc.mybatis3.generator.plugin.SumSelectivePlugin"/>
<plugin type="com.github.oceanc.mybatis3.generator.plugin.WhereSqlTextPlugin"/>
<plugin type="xyz.vsl.mybatis.generator.pluginsplus.ModelSettersChainPlugin"/>

则对应生产Java代码

example.sumPrice(); //注意要添加sum的字段
mapper.sumByExample(example);

WhereSqlTextPlugin

自定义sql插件 原作者地址:https://github.com/oceanc/mybatis3-generator-plugins 引入插件(保留原作者包名)

<plugin type="com.github.oceanc.mybatis3.generator.plugin.WhereSqlTextPlugin"/>
<plugin type="xyz.vsl.mybatis.generator.pluginsplus.ModelSettersChainPlugin"/>

则对应生产Java代码,addConditionSql中可以自定义sql

example.createCriteria().andIdEqualTo(1).addConditionSql("1=1");

ModelSettersChainPlugin

model层可以连续set的插件 原作者地址:https://github.com/vsl1978/mybatis-generator-pluginsplus 引入插件(保留原作者包名)

<plugin type="xyz.vsl.mybatis.generator.pluginsplus.ModelSettersChainPlugin"/>

则对应生产Java代码,你可以这样写

Test test = new Test().setId(2).setName("123").setPrice(123d);
mapper.upsert(test);

空文件

简介

mybatis-generator常用插件,持续更新 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/trytotry/mybatis-generator-xplugin.git
git@gitee.com:trytotry/mybatis-generator-xplugin.git
trytotry
mybatis-generator-xplugin
mybatis-generator-xplugin
master

搜索帮助