@Entity
Class People{
@Id
Private Long peoId;
Private List<Friend> friends;
}
@Entity
Class Friend{
@Id
private Long id;
private String type; private People person;
}
一个People类和一个Friend类。
数据库模型是这样的:
t_person t_friend
id | name id | friendType | personId | friendId
1 | "张三" 1 | “好友” | 1 | 2
2 | "李四" 2 | “挚友” | 1 | 3
3 | "王五" 3 | “狗友” | 1 | 4
4 | "王五a" 4 | “A友” | 2 | 4
5 | "王五b" 5 | “B友” | 2 | 5问题在于 personId和friendId都要映射到t_person表的id字段。 不知道如何去配置 , 请高手解答,xml或annotation的配置都行~~
Class People{
@Id
Private Long peoId;
Private List<Friend> friends;
}
@Entity
Class Friend{
@Id
private Long id;
private String type; private People person;
}
一个People类和一个Friend类。
数据库模型是这样的:
t_person t_friend
id | name id | friendType | personId | friendId
1 | "张三" 1 | “好友” | 1 | 2
2 | "李四" 2 | “挚友” | 1 | 3
3 | "王五" 3 | “狗友” | 1 | 4
4 | "王五a" 4 | “A友” | 2 | 4
5 | "王五b" 5 | “B友” | 2 | 5问题在于 personId和friendId都要映射到t_person表的id字段。 不知道如何去配置 , 请高手解答,xml或annotation的配置都行~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货