日期:2014-05-17 浏览次数:20731 次
@Eneity
public class A {
@Id
@GeneratedValue
private int id;
private Sreing name;
@OneToOne //这里该怎么写
private int bid;
//setter getter......
}
@Eneity
public class B {
@Id
@GeneratedValue //这里要写什么?
private int id;
private Sreing name;
//setter getter......
}
select * from A
@Entity
public class A {
//最好还是把这些注解写在getter上
@Id
@GeneratedValue
private int id;
private String name;
private int bid;
@OneToOne
@JoinColumn(name="bid",insertable=false,updatable=false)
private B b;
//setter getter......
}
@Eneity
public class B {
//最好还是把这些注解写在getter上
@Id
@GeneratedValue
private int id;
private String name;
@OneToOne(mappedBy="b")//双向一对一关联以A类的b属性配置来进行关联
private A a;
//setter getter......
}