mybatis一对多、延迟查询
2020-08-16 本文已影响0人
rainbowz
参考
https://blog.csdn.net/ncepu_Chen/article/details/97424811
实体类
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class User implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Long id;
/**
* 姓名
*/
private String name;
/**
* 年龄
*/
private Integer age;
/**
* 邮箱
*/
private String email;
private LocalDateTime updateTime;
private List<Accounts> accounts; // 一对多关系映射:主表实体应该包含从表实体的集合引用
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class Accounts implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
/**
* 金额
*/
private Double money;
/**
* 用户编号
*/
private Integer uid;
private User user;
}
Userdao接口
image.png
User xml文件
image.png
AccountDao
image.png
Account xml
image.png结果
image.png