SYS_Station类的定义如下:
@TableName("SYS_Station")
@Data
@ToString
public class SYS_Station
{
@TableId
private String Station_Code;
private String dept_code;
}
以下是测试代码:
@Test
public void test(){
MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(SYS_USER.class)
.innerJoin(SYS_Station.class,SYS_Station::getStation_Code,SYS_USER::getUSER_CODE);
var users = _userMapper.selectJoinList(SYS_USER.class,wrapper);
users.forEach(System.out::println);
}
执行以上测试会报以下错误:
Cannot invoke "com.github.yulichang.wrapper.segments.SelectCache.getColumn()" because the return value of "com.github.yulichang.wrapper.MPJAbstractLambdaWrapper.getCache(com.baomidou.mybatisplus.core.toolkit.support.SFunction)" is null
SYS_Station类的定义如下: @TableName("SYS_Station") @Data @ToString public class SYS_Station { @TableId private String Station_Code; private String dept_code; }
以下是测试代码: @Test public void test(){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(SYS_USER.class)
.innerJoin(SYS_Station.class,SYS_Station::getStation_Code,SYS_USER::getUSER_CODE);
var users = _userMapper.selectJoinList(SYS_USER.class,wrapper);
users.forEach(System.out::println);
}
执行以上测试会报以下错误: Cannot invoke "com.github.yulichang.wrapper.segments.SelectCache.getColumn()" because the return value of "com.github.yulichang.wrapper.MPJAbstractLambdaWrapper.getCache(com.baomidou.mybatisplus.core.toolkit.support.SFunction)" is null
如果将Station类的Station_Code字段的名称,修改为首字母小写,则不会报错。
原因是MPJAbstractLambdaWrapper类以下方法: protected SelectCache getCache(SFunction<?, ?> fn) { Class<?> aClass = LambdaUtils.getEntityClass(fn); Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass); return cacheMap.get(LambdaUtils.getName(fn)); } cacheMap中健值为Station_Code(首字母大写),LambdaUtils.getName(fn)方法得到的字段名为station_Code(首字母小写)