mybatis---一对一查询
作者:互联网
实体类
//多对一(mybatis中称之为一对一)的映射:一个账户只能属于一个用户 private User user; public User getUser() { return user; } public void setUser(User user) { this.user = user; }
接口
/** * 查询所有账户,并且获取每个账户所属的用户信息 * @return */ @Select("select * from account") @Results(id="accountMap",value = { @Result(id=true,column = "id",property = "id"), @Result(column = "uid",property = "uid"), @Result(column = "money",property = "money"), @Result(property = "user",column = "uid",one=@One(select="com.itheima.dao.IUserDao.findById",fetchType= FetchType.EAGER)) })
标签:uid,column,---,一对一,user,mybatis,property,id,Result 来源: https://www.cnblogs.com/dbconfig1/p/15538378.html