复杂的join 例子
join相同表
java
List<SysUser> list=QueryChain.of(sysUserMapper)
.select(SysUser.class)
.from(SysUser.class)
.join(JoinMode.INNER,SysUser.class,1,SysUser.class,2,on->on.eq(SysUser::getId,1,SysUser::getRole_id,2))
.list();
join子查询
java
SubQuery subQuery=SubQuery.create("sub")
.select(SysRole.class)
.from(SysRole.class)
.eq(SysRole::getId,1);
List<SysUser> list=QueryChain.of(sysUserMapper)
.select(SysUser.class)
.from(SysUser.class)
.join(JoinMode.INNER,SysUser.class,subQuery,on->on.eq(SysUser::getRole_id,subQuery.$outerField(SysRole::getId)))
.list();
返回2张相同表字段
java
List<SysUserVO> list=QueryChain.of(sysUserMapper)
.select(SysUser.class)
.select(SysUser.class,2)
.from(SysUser.class)
.join(JoinMode.INNER,SysUser.class,1,SysUser.class,2,on->on.eq(SysUser::getId,1,SysUser::getRole_id,2))
.returnType(SysUserVO.class)
.list();