@Entity
public class User {
private String mail;
private String password;
@OneToMany(mappedBy="user")
private List<UserGroup> userGroups;
}
@Embeddable
public class UserGroupPK {
private String mail;
private String role;
}
@Entity
public class UserGroup {
@EmbeddedId
private UserGroupPK id;
private String field;
@ManyToOne
@MapsId("mail")
private User user;
}
Hibernate創建兩個表:用戶(郵件,密碼)和用戶組(user_mail,角色,字段)。JPA外鍵列名
我需要將user_mail列重命名爲郵件。我試圖在UserGroupPK中添加@Column(name="mail")
,但沒有任何內容。
您是否使用Hibernate生成架構? – 2011-04-02 17:02:22
是的,休眠。 – Alf 2011-04-02 21:14:05