【发布时间】:2018-05-29 10:47:17
【问题描述】:
我有 2 类 User 和 Bottom , User 与 Bottom 有很多关系。 用户有 2 个复合键
用户ID
class TireId {
private String uId;
private String schoolId
}
用户实体:
@IdClass(UserId.class)
@Entity
Class User {
@Id
private String uId;
@Id
private String schoolId
@OneToMany(mappedBy="user")
private List<Bottom> bottoms;
}
底部标识:
class BottomId {
private String bId;
private String cId;
private String schoolId;
}
底层:
@IdClass(BottomId.class)
@Entity
class Bottom {
private String bId;
private String cId;
private String schoolId;
@ManyToOne
private User user;
}
在上述情况下,hibernate 将在底部表名 user_uId 和 user_schoolId 中创建 2 个附加列。
但我需要用户 oneToMany 与以下关系的关系
schoolId of user == schoolId of Bottom
and uId of user == cId of of Bottom
如何存档?
【问题讨论】: