ForeignKey 外键注解
说明
作用:就是在连表时,可是不用写ON 条件,框架自动添加ON条件
如何用?
java
@Data
@Table
public class SysUser {
@TableId
private Integer id;
private String userName;
private String password;
@ForeignKey(SysRole.class)
private Integer roleId;
private LocalDateTime createTime;
}
java
public class Demo {
@Autowired
private SysUserMapper sysUserMapper;
public void page() {
Pager<SysUser> pager= QueryChain.of(sysUserMapper)
.select(SysUser.class)
.from(SysUser.class)
.join(SysUser.class,SysRole.class)
.like(SysUser::getUserName,"abc")
.returnType(SysUser.class)
.paging(Pager.of(1));
}
}
不加此注解的话 需要 :
join(SysUser.class,SysRole.class,on -> on.eq(SysUser::getRoleId, SysRole::getId))