hibernate 配置文件问题请教一下
一对一单向外键映射,wife的主键由wifePK类的(id,name)确定Husband类
@Entity
public class Husband {
private int id;
private String name;
private Wife wife;
@Id
@GeneratedValue
public int getId() {
return id;
}
public String getName() {
return name;
}
@OneToOne
@JoinColumns(
{
@JoinColumn(name="wifeId", referencedColumnName="id"),
@JoinColumn(name="wifeName", referencedColumnName="name")
}
)
public Wife getWife() {
return wife;
}
wife类
@Entity
@IdClass(WifePK.class)
public class Wife {
private int id;
private String name;
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Id
public String getName() {
wifePK类
public class WifePK implements Serializable {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
请问这种映射关系,不用注解,用xml配置应该怎么写? java hibernate annotation 注解 xml --------------------编程问答-------------------- 我是发错板块了么,没人回复的???
补充:Java , Java EE