a表@Entity
public class a implements Serializable {
private int id;
private String name; private b bb; @JoinColumn(name = "outid")
@OneToOne(fetch=FetchType.LAZY)
public b getBb() {
return bb;
}

}
@Entity
public class b  implements Serializable{
private int id;

private a aa;

@OneToOne(mappedBy="bb")
public a getA() {
return aa;
}

}
然后我再  a表上面设置了  @OneToOne(fetch=FetchType.LAZY)
a表
id name outid
1  a    1
b表
id
1
我写了个 测试的 类 
public void test(){
a aa = aservice.getA(1);
b bb = bservice.getB(1);
if(bb.getId() == aa.getBb().getId()){
System.out.println(true);
}
System.out.println(aa.getBb());
}
这样  控制台 会输出 true
然后报错 说   org.hibernate.LazyInitializationException: could not initialize proxy - no Session
我不太明白    既然我吧 fetch=FetchType.LAZY
为什么   
aa.getBb().getId()这个能得到  
而且 我断点   里面   的 值是空的 ?希望大家帮我解释下    谢谢
到底 这个 机制 是什么样的