Open changyuansky opened 2 months ago
PR: https://github.com/bobo667/mybatis-plus-join/pull/9 @bobo667
解决方案:增加joinMasterAlias参数,让调用方可以指定要关联的主表是哪一个。
使用方法:
JoinLambdaWrapper<Goods> queryWrapper = new JoinLambdaWrapper<>(Goods.class, "goods").selectAll()
.leftJoin(Category.class, Category::getId, Goods::getCid, "c").selectAll().end()
.leftJoin(Category.class, Category::getId, Category::getPid, "c2", "c").end()
.leftJoin(Category.class, Category::getId, Category::getPid, "c3", "c2").end()
.leftJoin(Category.class, Category::getId, Category::getPid, "c4", "c3").end();
在commitid为bc76f750的提交中,已经存在过对此问题的修复,但是存在局限性。
局限性为:仅解决了整个查询只有自连接的情况。 举例:(这个sql是可以被正确拼接的)
以下这种情况的sql无法被正确拼接: 期望:
代码:
拼出来的sql为: