tkmbatis 日志_Mybatis 通用 Mapper首页、文档和下载

Mybatis通用Mapper

极其方便的使用Mybatis单表的增删改查

支持单表操作,不支持通用的多表联合查询

优点?

通用Mapper可以极大的方便开发人员。

为了让您更方便的了解通用Mapper,下面贴一段代码来看实际效果。

通用Mapper

通用Mapper可以缓存,全部针对单表操作,每个实体类都需要继承通用Mapper接口来获得通用方法。

示例代码:

CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);

//查询全部

List countryList = mapper.select(new Country());

//总数

Assert.assertEquals(183, countryList.size());

//通用Example查询

Example example = new Example(Country.class);

example.createCriteria().andGreaterThan("id", 100);

countryList = mapper.selectByExample(example);

Assert.assertEquals(83, countryList.size());

//MyBatis-Generator生成的Example查询

CountryExample example2 = new CountryExample();

example2.createCriteria().andIdGreaterThan(100);

countryList = mapper.selectByExample(example2);

Assert.assertEquals(83, countryList.size());

CountryMapper代码如下:

public interface CountryMapper extends Mapper {

}

这里不说更具体的内容,如果您有兴趣,可以查看下面的项目文档

实体类注解

从上面效果来看也能感觉出这是一种类似hibernate的用法,因此也需要实体和表对应起来,因此使用了JPA注解。更详细的内容可以看下面的项目文档。

Country代码:

public class Country {

@Id

private Integer id;

@Column

private String countryname;

private String countrycode;

//省略setter和getter方法

}

通用Mapper支持Mybatis-3.2.4及以上版本

Maven坐标以及下载地址

如果你使用Maven,只需要添加如下依赖:

1

2

3

4

5

6

com.github.abel533

mapper

x.x.x

如果你想引入Jar包,你可以从下面的地址下载:

由于通用Mapper依赖JPA,所以还需要下载persistence-api-1.0.jar:

项目文档

通用Mapper

作者信息

Mybatis工具群: 211286137 (Mybatis相关工具插件等等)

推荐使用Mybatis分页插件:PageHelper分页插件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值