• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

mybatis.flying: mybatis最好的插件组合

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

mybatis.flying

开源软件地址:

https://gitee.com/limeng32/mybatis.flying

开源软件介绍:

mybatis.flying - 极光 (Aurora)

Build StatusCodecovMaven CentralGitHub releaseLicense

项目介绍请见 flying-doc.limeng32.com(国外)https://flyingdoc.gitee.io(国内) ,国内代码托管网站请见 gitee.com/limeng32/mybatis.flying,我们为开发最好的 mybatis 插件而努力。

flying 是一个可以极大增加 mybatis 开发速度的插件组,它提供了一种全新的操作数据的方式,希望能对您有所帮助。

众所周知,mybatis 虽然易于上手,但放到互联网环境下使用时,不可避免的要面对诸如‘’一级缓存存在脏数据‘’、‘’需要写大量明文 SQL 语句‘’等问题。对于这些问题 mybatis 的开发团队选择了一种谦逊的方式,他们开放 mybatis 接口,允许用户开发插件,按自己的方式来解决这些问题。于是,一切 ORM 领域相关的问题在 mybatis 上通过插件都有了解决方案。

flying 主要特点:

以前我们在 mapper.xml 中要写很复杂的 sql 语句,但现在在 mapper.xml 中只需这样:

    <select id="select" resultMap="result">        {"action":"select#{?}"}    </select>    <select id="selectOne" resultMap="result">        {"action":"selectOne"}    </select>    <insert id="insert">        {"action":"insert"}    </insert>    <update id="update">        {"action":"update"}    </update>    <delete id="delete">        {"action":"delete"}    </delete>

再在您的实体类上加上这样一些标注:

package myPackage;import javax.persistence.Column;import javax.persistence.Id;import javax.persistence.Table;    @Table(name = "account")public class Account {    @Id    @Column    private Integer id;	        @Column    private java.lang.String name;    @Column    private Integer age;	        /* 省略 getter 和 setter */}

flying 就完全明白您的数据结构和您想做的事情了。 接下来您增删改查这个实体就会变得非常简单:

    /* 新增 */    Account newAccount = new Account();    newAccount.setName("ann");    newAccount.setAge(18);    accountService.insert(newAccount);    /* 按主键查询 */    Account account = accountService.select(newAccount.getId());        /* 按姓名查询,这里忽略了年龄 */    Account accountC1 = new Account();    accountC1.setName("ann");    Account account1 = accountService.selectOne(accountC1);    /* account1 和 account 代表相同的业务数据 */        /* 按年龄查询,这里忽略了姓名 */    Account accountC2 = new Account();    accountC2.setAge(18);    Account account2 = accountService.selectOne(accountC2);    /* account2 和 account 代表相同的业务数据 */        /* 按姓名和年龄查询 */    Account accountC3 = new Account();    accountC3.setName("ann");    accountC3.setAge(18);    Account account3 = accountService.selectOne(accountC3);    /* account3 和 account 代表相同的业务数据 */        /* 修改 */    account.setName("bob");    accountService.update(newAccount);        /* 按主键删除 */    accountService.delete(newAccount);

由于 flying 掌握了您全部的数据结构和实体关系,所以操作数据变得非常简单,您再也不需要定义 “getAccountById、getAccountByName、getAccountByAge” 这样重复性强的方法了,由此带来更大的好处是您的 service 层只需要关注事务方面的逻辑即可,它从低级代码中完全解放了出来。以上只是 flying 功能的冰山一角,其它的功能如多表联查、分页、乐观锁、或逻辑查询、索引、复杂外键关系、批量执行等 flying 都有简单的解决方案,您可以在 flying-doc.limeng32.com(国外)https://flyingdoc.gitee.io(国内)中进行查看。

flying 特点总结如下:

  • 数据操作入参和返回类型都是自定义的实体类,完全 no sql,杜绝各种‘’手滑‘’,项目可随意重构。

  • 非侵占工作机制,可以和您已有的 mybatis 方法协同工作。

  • 灵活定制查询字段黑名单和白名单,方便您管理敏感数据。

  • 可以自定义主键生成器,全面支持或逻辑查询。(初雪版新增特性)

  • 支持复杂的外键关联方式。(清明版新增特性)

  • 支持使用索引查询,支持批量执行增删改。(极光版新增特性)

flying 获取方式:

flying 最新版的 maven 坐标为:

    <groupId>com.github.limeng32</groupId>    <artifactId>mybatis.flying</artifactId>    <version>1.0.0</version>

mybatis 版本与 flying 版本的对应关系见下:

mybatis 版本flying 版本英文标题
3.4.x0.9.4 阳春sunny-spring
3.4.x0.9.9 清明qing-ming
3.4.x1.0.0 极光Aurora

flying 代码示例:

我们还为您提供了一个快速上手的示例:

  1. 最新版本demo:https://gitee.com/limeng32/flying-demo-use-springboot

更多内容请您参见软件文档 flying-doc.limeng32.com(国外)https://flyingdoc.gitee.io(国内)。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap