Sign inSign up

[Open Source] The Perfect Companion to MyBatis-Plus. Enhances Without Changing Existing Functionality, Simplifying Development and Improving Efficiency

Open SourceOther Dev Tools
2026-06-28 06:09 4 views • 0 downloads 0KB
[Open Source] The Perfect Companion to MyBatis-Plus. Enhances Without Changing Existing Functionality, Simplifying Development and Improving Efficiency

1. Project Overview

Mybatis-Plus-Join-Logo

MyBatis-Plus-Join

Built to Simplify Development and Improve Productivity

Enjoy the MyBatis-Plus experience with support for multi-table join queries! Provides MyBatis-Plus-style join operations, including leftJoin, rightJoin, and innerJoin.

2. Open Source License

Licensed under Apache-2.0

3. Screenshots

Image

4. Feature Overview

MyBatis-Plus-Join

The Perfect Companion to MyBatis-Plus. Enhances Without Changing Existing Functionality, Built to Simplify Development and Improve Efficiency.

Seamless Integration

Enhances without changing existing functionality. Introducing it has no impact on existing projects and integrates as smoothly as silk.

Efficiency First

With just a simple configuration, you can quickly perform multi-table join operations and save a significant amount of time.

Rich Features

Supports column enumeration, aliases, logical deletion, TypeHandle, one-to-one, one-to-many, and more.

5. Tech Stack

Usage

Installation

  • Maven
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.5.3</version>
</dependency>
Null
  • Gradle
implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.5.3'
Apache
Alternatively, clone the code locally, run mvn install, and then add the dependency listed above.
Note: MyBatis-Plus version 3.1.2 or later is required.

Usage

  • Mapper extends MPJBaseMapper

Lambda-style Usage (MPJLambdaWrapper)

Simple Multi-Table Join Query

class test {
    @Resource
    private UserMapper userMapper;
    void testJoin() {
        // Same as MyBatis-Plus: The generic type of MPJLambdaWrapper must be the main table's generic type, and the main table's Mapper must be used to execute the query
        MPJLambdaWrapper<UserDO> wrapper = JoinWrappers.lambda(UserDO.class)
                .selectAll(UserDO.class)// Query all fields from the user table
                .select(UserAddressDO::getTel)// Query the tel field from the user_address table
                .selectAs(UserAddressDO::getAddress, UserDTO::getUserAddress)// Alias
                .select(AreaDO::getProvince, AreaDO::getCity)
                .leftJoin(UserAddressDO.class, UserAddressDO::getUserId, UserDO::getId)
                .leftJoin(AreaDO.class, AreaDO::getId, UserAddressDO::getAreaId)
                .eq(UserDO::getId, 1)
                .like(UserAddressDO::getTel, "1")
                .gt(UserDO::getId, 5);
        // Multi-table join query returning a custom ResultType
        List<UserDTO> list = userMapper.selectJoinList(UserDTO.class, wrapper);
        // Paginated query (requires the MyBatis-Plus pagination plugin to be enabled)
        Page<UserDTO> listPage = userMapper.selectJoinPage(new Page<>(2, 10), UserDTO.class, wrapper);
    }
}
PHP

// Corresponding SQL

SELECT
    t.id, t.name, t.sex, t.head_img,
    t1.tel, t1.address AS userAddress,
    t2.province, t2.city
FROM
    user t
    LEFT JOIN user_address t1 ON t1.user_id = t.id
    LEFT JOIN area t2 ON t2.id = t1.area_id
WHERE (
    t.id = ?
    AND t1.tel LIKE ?
    AND t.id > ?)
SQL
#1
资源直链https://gitee.com/best_handsome/mybatis-plus-join
Download