在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:mybatis-generator-xplugin开源软件地址:https://gitee.com/trytotry/mybatis-generator-xplugin开源软件介绍:mybatis-generator-xplugin收集了很多mybatis-generator的插件,都是自己项目中用到的,为了方面使用,会上传到中心maven库,凡是用了其他人的插件,都会说明,如有冒犯,请告知,立马删除。邮箱:[email protected] 当初就是因为引用不方便,所以建了这个工程,集合了很多好用的插件,当前版本0.0.1 <dependency> <groupId>com.trytotry</groupId> <artifactId>mybatis-generator-xplugin</artifactId> <version>0.0.1</version></dependency> OverIsMergeablePlugin在生产xml文件的时候,默认会追加方法,而不会覆盖重写,找了很多方法,终于找到这个有用的,谢谢作者 <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); SumSelectivePluginsum插件原作者地址: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"); ModelSettersChainPluginmodel层可以连续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); |
请发表评论