diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java index bb768e87..463417cf 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java @@ -350,7 +350,8 @@ public String getTableNameEnc(String tableName) { */ public MPJLambdaQueryWrapper lambda() { return new MPJLambdaQueryWrapper<>(getEntity(), getEntityClass(), from, sqlSelect, paramNameSeq, paramNameValuePairs, - expression, lastSql, sqlComment, getSqlFirstField(), selectColumns, ignoreColumns, selectDistinct, ifExists); + expression, lastSql, sqlComment, getSqlFirstField(), selectColumns, ignoreColumns, selectDistinct, ifExists) + .setAlias(this.alias); } @Override diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java index 581dfa35..ee27b335 100644 --- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java +++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java @@ -128,4 +128,17 @@ void test6() { System.out.println(userDO); } + @Test + void test7() { + ThreadLocalUtils.set("SELECT tt.id AS idea, tt.user_id AS uuid, tt.tenant_id FROM user_tenant tt WHERE (tt.id <= ?) AND tt.tenant_id = 1"); + MPJQueryWrapper wrapper = new MPJQueryWrapper() + .setAlias("tt") + .selectAll(UserTenantDO.class,"tt") + .le("tt.id ", 10); + System.out.println(wrapper.getAlias()); + List userDO = userTenantMapper.selectJoinList(UserTenantDO.class, wrapper.lambda()); + System.out.println(wrapper.getAlias()); + System.out.println(userDO); + } + }