mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
This commit is contained in:
parent
05191f49b2
commit
cc1b03ad3c
@ -27,6 +27,14 @@ public class SelectObjs extends com.baomidou.mybatisplus.core.injector.methods.S
|
||||
copyAndSetTableName(tableInfo, getTableName(tableInfo)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlSelectObjsColumns(TableInfo table) {
|
||||
String selectColumns = super.sqlSelectObjsColumns(table);
|
||||
return SqlScriptUtils.convertChoose(String.format("%s == null or !(%s instanceof %s)", Constants.WRAPPER, Constants.WRAPPER, MPJBaseJoin.class.getName()),
|
||||
selectColumns, mpjSqlSelectColumns() + StringPool.SPACE + selectColumns);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String sqlWhereEntityWrapper(boolean newLine, TableInfo table) {
|
||||
return SqlScriptUtils.convertChoose(String.format("%s == null or !(%s instanceof %s)", Constants.WRAPPER, Constants.WRAPPER, MPJBaseJoin.class.getName()),
|
||||
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@DynamicTableName
|
||||
@FieldNameConstants
|
||||
@TableName(value = "`user`")
|
||||
@TableName(value = "`user`", autoResultMap = true)
|
||||
public class UserDO extends ID<Integer> implements Serializable {
|
||||
|
||||
private Integer pid;
|
||||
|
@ -516,6 +516,19 @@ class LambdaWrapperTest {
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 别名测试
|
||||
*/
|
||||
@Test
|
||||
void testObj() {
|
||||
ThreadLocalUtils.set("SELECT DISTINCT t1.id FROM `user` t LEFT JOIN `user` t1 ON (t1.pid = t.id) WHERE t.del=false AND t1.del=false");
|
||||
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
||||
.distinct()
|
||||
.select(UserDO::getId)
|
||||
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId);
|
||||
List<Object> list = userMapper.selectObjs(wrapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTableAlias() {
|
||||
ThreadLocalUtils.set("SELECT t.id,\n" +
|
||||
|
Loading…
x
Reference in New Issue
Block a user