Hibernate version:2.16
The generated SQL (using fetch join):
Code:
Hibernate: select this.studentcode as studentc1_11_, this.name as name11_, this.identitynumber as identity3_11_, this.birthday as birthday11_, this.entrancedate as entrance5_11_, this.recruitarea as recruita6_11_, this.isvalidator as isvalida7_11_, this.classcode as classcode11_, this.entrancetypecode as entrance9_11_, this.nationcode as nationcode11_, this.partycode as partycode11_, this.sexcode as sexcode11_, this.studenttypecode as student13_11_, this.nativeplace as nativep14_11_, this.schoolareacode as schoola15_11_, this.origincode as origincode11_, classlibra1_.code as code0_, classlibra1_.name as name0_, classlibra1_.grade as grade0_, classlibra1_.classnumber as classnum4_0_, classlibra1_.teachercode as teacherc5_0_, classlibra1_.memo as memo0_, classlibra1_.departmentcode as departme7_0_, classlibra1_.specialtycode as specialt8_0_, classlibra1_.educationcode as educatio9_0_, codedepart2_.code as code1_, codedepart2_.status as status1_, codedepart2_.treecode as treecode1_, codedepart2_.caption as caption1_, codedepart2_.mnemonic as mnemonic1_, codedepart2_.schoolarea as schoolarea1_, codestuden3_.code as code2_, codestuden3_.caption as caption2_, codestuden3_.captionshort as captions3_2_, codestuden3_.mnemonic as mnemonic2_, codestuden3_.treecode as treecode2_, codestuden3_.status as status2_, codestuden3_.departmentcode as departme7_2_, codestedut4_.steducode as steducode3_, codestedut4_.caption as caption3_, codetypeen5_.code as code4_, codetypeen5_.status as status4_, codetypeen5_.caption as caption4_, codetypeen5_.treecode as treecode4_, codetypeen5_.mnemonic as mnemonic4_, codenation6_.code as code5_, codenation6_.status as status5_, codenation6_.caption as caption5_, codenation6_.treecode as treecode5_, codenation6_.mnemonic as mnemonic5_, codeparty7_.code as code6_, codeparty7_.status as status6_, codeparty7_.caption as caption6_, codeparty7_.treecode as treecode6_, codeparty7_.mnemonic as mnemonic6_, codesex8_.code as code7_, codesex8_.caption as caption7_, codesex8_.status as status7_, codesex8_.treecode as treecode7_, codesex8_.mnemonic as mnemonic7_, codestuden9_.studenttypecode as studentt1_8_, codestuden9_.caption as caption8_, codeschool10_.code as code9_, codeschool10_.status as status9_, codeschool10_.caption as caption9_, codeschool10_.treecode as treecode9_, codeschool10_.mnemonic as mnemonic9_, codestorig11_.code as code10_, codestorig11_.caption as caption10_ from T_StudentNew this left outer join T_ClassLibrary classlibra1_ on this.classcode=classlibra1_.code left outer join T_CodeDepartment codedepart2_ on classlibra1_.departmentcode=codedepart2_.code left outer join T_CodeStudentSpecialty codestuden3_ on classlibra1_.specialtycode=codestuden3_.code left outer join T_CodeStEduType codestedut4_ on classlibra1_.educationcode=codestedut4_.steducode left outer join T_CodeTypeEntrance codetypeen5_ on this.entrancetypecode=codetypeen5_.code left outer join T_CodeNationality codenation6_ on this.nationcode=codenation6_.code left outer join T_CodeParty codeparty7_ on this.partycode=codeparty7_.code left outer join T_CodeSex codesex8_ on this.sexcode=codesex8_.code left outer join T_CodeStudentType codestuden9_ on this.studenttypecode=codestuden9_.studenttypecode left outer join T_CodeSchoolArea codeschool10_ on this.schoolareacode=codeschool10_.code left outer join T_CodeStOrigin codestorig11_ on this.origincode=codestorig11_.code where 1=1
The generated SQL (no fetch join):forget it ,too manys sqls
find methidCode:
protected List findall(Session ses, Class clazz) throws DAOException {
List rs = null;
try {
// Query query = ses.createQuery("from "+clazz);
// rs = query.list();
rs = ses.createCriteria(clazz).list();
} catch (Exception e) {
e.printStackTrace();
throw new DAOException(e);
}
return rs;
}
if i used fetch join ,hibernate will create 1 sql ,but execute time is 3xxx ms
if not ,hibernate will create many sqls ,but execute time is 4xx ms
if i used left join in jdbc the time is 4x ms
why ??
the hibernate is slow in fetch join