I'm using the framework "mybatis-mp" for development. The framework's URL is here.
Framework version: 1.5.8
VO class
@Data
@ResultEntity(SysUser.class)
public class SysUserVo {
private Integer id;
private String userName;
private Integer roleId
@ResultEntityField(property = "password")
private String pwd;
@Fetch(source = SysUser.class, property = "roleId", target = SysRole.class, targetProperty = "id")
private SysRoleVo sysRole;
}
Query code
List<SysUserRoleVO> list = QueryChain.of(sysUserMapper)
.like(SysUser::getUser,"ad")
.returnType(SysUserRoleVO.class)
.list();
I want to load SysRole only when SysRole.type = 1. What can I do?
thank you,I'm had ask author,the Solution is :
List<SysUserRoleVO> list = QueryChain.of(sysUserMapper)
.like(SysUser::getUser,"ad")
.fetchFilter(SysUserRoleVO::getSysRole, where -> {
where.eq(SysRole::getType, 0);
})
.returnType(SysUserRoleVO.class)
.list();
the sql will be :SELECT * FROM sys_role WHERE id=? and type = 0
the function is need than 1.6.0 version