-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: using fetch join or not
PostPosted: Thu Sep 23, 2004 9:46 pm 
Newbie

Joined: Tue Aug 10, 2004 12:50 am
Posts: 4
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 methid
Code:
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 2:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
how many objects are returned?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: details
PostPosted: Fri Sep 24, 2004 2:58 am 
Newbie

Joined: Tue Aug 10, 2004 12:50 am
Posts: 4
3000-4000 records
jdbc :
if i used "select * from ...."
the excute time is also long maybe 2xxx ms
but if i used "select a as a1,b as b1 ... "to improve sql
the excute time will be 5x--2xx ms very quickly
hibernate:
if do not use fetch join the excute time is 3xx-4xx ms
i accept it too,it is also quickly,but hibernate create so many sqls
that i want reduce them .So i used fetch join,but the result make me
surprised,it's too slow ,sometimes the excute time will be 4xxx even 5xxxms,why???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 3:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
do you want to update these objects or only "read" them?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: yes ,i want read and update them
PostPosted: Sat Sep 25, 2004 9:24 pm 
Newbie

Joined: Tue Aug 10, 2004 12:50 am
Posts: 4
at the same time ,there are hundreds of clients to access my web container but the read is the most method ,what can i do?
thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.