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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate generated multiple select statements
PostPosted: Thu Oct 06, 2005 5:52 pm 
Newbie

Joined: Thu Oct 06, 2005 5:41 pm
Posts: 1
I'm trying to retrieve some data from database by joining 4 tables.
One approach is that I can just write a single SQL statement to do the work.
But if I use HQL, behind the scene, Hibernate generated more than 8 SQL satements.
My question is that will this be an performance impact on my application? What benefit does Hibernate provide in terms of performance in my case?
(It's a silly question, but I still hope to find a explanation/answer...).
Thanks.


Top
 Profile  
 
 Post subject: strategy
PostPosted: Thu Oct 06, 2005 6:38 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Firstly, you can control Hibernate fetch strategy, for example in the mapping you can specify fetch="join"
http://www.hibernate.org/hib_docs/v3/re ... -outerjoin

Note: in 3.0.5 fetch=”join” has no effect on retrieving object as a part of HQL select, but works properly when we ask session for the object, i.e. session.get( ObjectClass.class, id );

Secondly: getting all the objects with JOIN might actually cause performance to deteriorate. It may happen when linked tables have small number of records, in this case it is cheaper to get the objects from session or second level cache than transfer them from DB as a result of a big jojn.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.