-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Labels
Description
实体类内 支持嵌套 对象
用法1:内嵌对象
@SearchBean(tables="user u, profile p", joinCond="u.id = p.user_id")
public class User {
// 和主表数据在同一个 SQL 查出来,参数 value=p 指定该对象的数据来自 profile 表
@DbFiled(type=DbType.INLINE, value="p")
private Profile profile;
// 省略其它...
}
public class Profile {
private String address;
// 省略其它...
}
用法2:内嵌列表
@SearchBean(tables="user u, user_role ur, role r", joinCond="u.id = ur.user_id and ur.role_id = r.id")
public class User {
private Long id;
// 类似 mybatis 的 <collection> 标签
// 和主表数据在同一个 SQL 查出来,value=r 指定该集合的数据来自 role 表
@DbFiled(type=DbType.COLLECTION, value="r")
private List<Role> roles;
// 省略其它...
}
public class Role {
private Long id;
// 省略其它...
}