springboot整和mybatis实现多表查询
1、一对一查询(例一个用户一个账户)
1.1、实体类
//用户实体
@Data
public class UserInfo {
private int u_id;
private String name;
private Account account;
}
//账户实体
@Data
public class Account {
private int a_id;
private String aname;
private double money;
}
1.2、数据库表
用户表
账户表
1.3、持久层接口
@Select("select * from userInfo where name=#{name} ")
@Results({
//@Result(property = "a_id",column = "a_id"),
@Result(property ="account",column = "a_id",javaType = Account.class,
one = @One(select="com.bbz.dao.AccountDao.findById",fetchType = FetchType.LAZY))
})
public