Proyectos
Ver en GitHub
yulichang/mybatis-plus-join
Acerca de
MyBatis-Plus con soporte para consultas con joins, que ofrece operaciones de unión al estilo de MyBatis-Plus, como left join y right join
Datos y análisisCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -2
- in 1 month
- -1
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalMyBatis-Plus-Join
为简化开发工作、提高生产率而生
对 MyBatis-Plus 多表查询的扩展 | 演示工程 | 使用文档 | 点个Star支持一下吧 (☆▽☆)
可添加作者微信,咨询问题或提供意见与建议
使用文档WIKI
使用方法
安装
- Maven
<dependency> <groupId>com.github.yulichang</groupId> <artifactId>mybatis-plus-join-boot-starter</artifactId> <version>1.5.9</version> </dependency> - Gradle
或者clone代码到本地执行implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.5.9'mvn install, 再引入以上依赖
版本对应关系:
| Mybatis-Plus-Join | Mybatis-Plus |
|---|---|
| 1.5.9 | 3.5.17+ |
| 1.5.8 | 3.1.2 - 3.5.16 |
使用
- mapper继承MPJBaseMapper
Lambda形式用法(MPJLambdaWrapper)
简单的连表查询
class test {
@Resource
private UserMapper userMapper;
void testJoin() {
MPJLambdaWrapper<UserDO> wrapper = JoinWrappers.lambda(UserDO.class)
.selectAll(UserDO.class)
.select(AddressDO::getTel)
.leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
.eq(UserDO::getId, 1)
.like(AddressDO::getTel, "1");
//连表查询 返回自定义ResultType
List<UserDTO> list = userMapper.selectJoinList(UserDTO.class, wrapper);
//分页查询 (需要启用 mybatis plus 分页插件)
Page<UserDTO> listPage = userMapper.selectJoinPage(new Page<>(2, 10), UserDTO.class, wrapper);
}
}
对应sql
SELECT
t.id, t.name, t.sex, t.head_img,
t1.tel
FROM user t
LEFT JOIN address t1 ON t1.user_id = t.id
WHERE ( t.id = ? AND t1.tel LIKE ? )
完整使用文档 wiki
用爱发电
Explorar proyectos relacionados
Cargando…