原创  lazy(延迟加载) 收藏

 
Student 和Department 部分配置文件如下
Department
 
设置:lazy=‘true
执行下面的代码
 
Transaction tx = session.beginTransaction();
              String str="select dep from XyDepartment dep ";
              session.find(str);
              tx.commit();
输出的语句为:
Hibernate: select xydepart0_.DEP_ID as DEP_ID, xydepart0_.CODE as CODE, xydepart0_.NAME as NAME from LIU.XY_DEPARTMENT xydepart0_
 
设置:lazy=‘false’(如果不设置,默认为false
输出语句:
Hibernate: select xydepart0_.DEP_ID as DEP_ID, xydepart0_.CODE as CODE, xydepart0_.NAME as NAME from LIU.XY_DEPARTMENT xydepart0_z
Hibernate: select xy_corus0_.CORU_ID as CORU_ID__, xy_corus0_.CORU_ID as CORU_ID, xy_corus0_.DEP_ID as DEP_ID, xy_corus0_.NAME as NAME, xy_corus0_.SCORE as SCORE from LIU.XY_CORUSE xy_corus0_ where xy_corus0_.DEP_ID=?
 
Hibernate: select xy_teach0_.TEA_ID as TEA_ID__, xy_teach0_.TEA_ID as TEA_ID, xy_teach0_.DEP_ID as DEP_ID, xy_teach0_.NAME as NAME from LIU.XY_TEACHER xy_teach0_ where xy_teach0_.DEP_ID=?
Hibernate: select xy_stude0_.STU_ID as STU_ID__, xy_stude0_.STU_ID as STU_ID, xy_stude0_.DEP_ID as DEP_ID, xy_stude0_.NAME as NAME, xy_stude0_.PASSWORD as PASSWORD, xy_stude0_.SCORE as SCORE from LIU.XY_STUDENT xy_stude0_ where xy_stude0_.DEP_ID=?
Hibernate: select xy_conca0_.CAT_ID as CAT_ID__, xy_conca0_.CAT_ID as CAT_ID, xy_conca0_.TEA_ID as TEA_ID, xy_conca0_.STU_ID as STU_ID, xy_conca0_.ADDRESS as ADDRESS, xy_conca0_.PHONE as PHONE, xy_conca0_.EMAIL as EMAIL from LIU.XY_CONCACT xy_conca0_ where xy_conca0_.STU_ID=?
Hibernate: select xy_histo0_.HIS_ID as HIS_ID__, xy_histo0_.HIS_ID as HIS_ID, xy_histo0_.CLA_ID as CLA_ID, xy_histo0_.STU_ID as STU_ID, xy_histo0_.MAKING as MAKING from LIU.XY_HISTORY xy_histo0_ where xy_histo0_.STU_ID=?
Hibernate: select xy_corus0_.CORU_ID as CORU_ID__, xy_corus0_.CORU_ID as CORU_ID, xy_corus0_.DEP_ID as DEP_ID, xy_corus0_.NAME as NAME, xy_corus0_.SCORE as SCORE from LIU.XY_CORUSE xy_corus0_ where xy_corus0_.DEP_ID=?
Hibernate: select xy_teach0_.TEA_ID as TEA_ID__, xy_teach0_.TEA_ID as TEA_ID, xy_teach0_.DEP_ID as DEP_ID, xy_teach0_.NAME as NAME from LIU.XY_TEACHER xy_teach0_ where xy_teach0_.DEP_ID=?
Hibernate: select xy_stude0_.STU_ID as STU_ID__, xy_stude0_.STU_ID as STU_ID, xy_stude0_.DEP_ID as DEP_ID, xy_stude0_.NAME as NAME, xy_stude0_.PASSWORD as PASSWORD, xy_stude0_.SCORE as SCORE from LIU.XY_STUDENT xy_stude0_ where xy_stude0_.DEP_ID=?
Hibernate: select xy_conca0_.CAT_ID as CAT_ID__, xy_conca0_.CAT_ID as CAT_ID, xy_conca0_.TEA_ID as TEA_ID, xy_conca0_.STU_ID as STU_ID, xy_conca0_.ADDRESS as ADDRESS, xy_conca0_.PHONE as PHONE, xy_conca0_.EMAIL as EMAIL from LIU.XY_CONCACT xy_conca0_ where xy_conca0_.STU_ID=?
Hibernate: select xy_histo0_.HIS_ID as HIS_ID__, xy_histo0_.HIS_ID as HIS_ID, xy_histo0_.CLA_ID as CLA_ID, xy_histo0_.STU_ID as STU_ID, xy_histo0_.MAKING as MAKING from LIU.XY_HISTORY xy_histo0_ where xy_histo0_.STU_ID=?
Hibernate: select xy_corus0_.CORU_ID as CORU_ID__, xy_corus0_.CORU_ID as CORU_ID, xy_corus0_.DEP_ID as DEP_ID, xy_corus0_.NAME as NAME, xy_corus0_.SCORE as SCORE from LIU.XY_CORUSE xy_corus0_ where xy_corus0_.DEP_ID=?
Hibernate: select xy_teach0_.TEA_ID as TEA_ID__, xy_teach0_.TEA_ID as TEA_ID, xy_teach0_.DEP_ID as DEP_ID, xy_teach0_.NAME as NAME from LIU.XY_TEACHER xy_teach0_ where xy_teach0_.DEP_ID=?
Hibernate: select xy_stude0_.STU_ID as STU_ID__, xy_stude0_.STU_ID as STU_ID, xy_stude0_.DEP_ID as DEP_ID, xy_stude0_.NAME as NAME, xy_stude0_.PASSWORD as PASSWORD, xy_stude0_.SCORE as SCORE from LIU.XY_STUDENT xy_stude0_ where xy_stude0_.DEP_ID=?
Hibernate: select xy_conca0_.CAT_ID as CAT_ID__, xy_conca0_.CAT_ID as CAT_ID, xy_conca0_.TEA_ID as TEA_ID, xy_conca0_.STU_ID as STU_ID, xy_conca0_.ADDRESS as ADDRESS, xy_conca0_.PHONE as PHONE, xy_conca0_.EMAIL as EMAIL from LIU.XY_CONCACT xy_conca0_ where xy_conca0_.STU_ID=?
Hibernate: select xy_histo0_.HIS_ID as HIS_ID__, xy_histo0_.HIS_ID as HIS_ID, xy_histo0_.CLA_ID as CLA_ID, xy_histo0_.STU_ID as STU_ID, xy_histo0_.MAKING as MAKING from LIU.XY_HISTORY xy_histo0_ where xy_histo0_.STU_ID=?
 
 
 

发表于 @ 2007年03月16日 10:49:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:hibernate 写入 clob, Blob  | 新一篇:inverse(控制反转)

  • 发表评论
  • 评论内容:
  •  
Copyright © hql638
Powered by CSDN Blog