如题,有Husband和Wife的两个类,他们是一对一的:
在Husband中,关于wife的注解 @OneToOne(mappedBy="husband",cascade={CascadeType.ALL},fetch=FetchType.LAZY)
public Wife getWife() {
return wife;
}在Wife中,关于husband的注解@JoinColumn(name="husband_hid")
@OneToOne(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
public Husband getHusband() {
return husband;
}我在Husband中的注解是lazy,所以我get(Husband.class,id)的时候,按理说不应该加载出Wife呀,可是它却打印出来了!
在控制台下显示的sql语句也打印了:Hibernate: 
    select
        husband0_.hid as hid0_0_,
        husband0_.name as name0_0_ 
    from
        zf_husband husband0_ 
    where
        husband0_.hid=?
Hibernate: 
    select
        wife0_.wid as wid1_1_,
        wife0_.husband_hid as husband3_1_1_,
        wife0_.name as name1_1_,
        husband1_.hid as hid0_0_,
        husband1_.name as name0_0_ 
    from
        zf_wife wife0_ 
    left outer join
        zf_husband husband1_ 
            on wife0_.husband_hid=husband1_.hid 
    where
        wife0_.husband_hid=?
这是怎么回事呀,设置lazy不是不查询了吗?
我测试的方法:@Test
public void testSelectHusbandWithWife() {
Session session = cfg.buildSessionFactory().getCurrentSession();
session.beginTransaction();
Husband husband = (Husband)session.get(Husband.class,3);
session.getTransaction().commit();
System.out.println(husband.toString());
System.out.println(husband.getWife().getName());
}我重写了toString()方法。