-->
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: How to use joins in HQL queries
PostPosted: Tue May 03, 2005 1:51 am 
Newbie

Joined: Tue Dec 28, 2004 6:25 am
Posts: 16
Can anybody please guide me on how to use different types of joins in hibernate hql queries.

If possible send me links of the tutorials explaining the usage


Top
 Profile  
 
 Post subject: HQL With Joins
PostPosted: Tue May 03, 2005 4:53 am 
Newbie

Joined: Fri Apr 29, 2005 4:58 am
Posts: 12
Location: Chennai INDIA
Outer Joins and Explicit Fetching
Generally, one of the best way to improve performance is to limit the number of trips to the database. Hibernate has a number ways its handles the N+1 issue. Associations can be explicitly flagged for outer join fetching (via outer-join="true"), and you can add outer join fetching to HQL statements. For example...

/**
* @hibernate.many-to-one column="gold_claim_id"
* cascade="save-update" outer-join="true"
*/
public GoldClaim getGoldClaim() { return goldClaim; }

// This does one select and fetches both the Miner and GoldClaim
// and maps them correctly.

Miner m = (Miner) session.load(Miner.class, new Long(1));

In addition, when selecting lists or dealing with collection associations, you can use an explicit outer join fetch, like so...

// Issues a single select, instead of 1 + N (where N is the # miners)
List list = session.find("from Miner m left join fetch m.goldClaim");



--------------------------------------------------------

Please Refer Also

http://www.tim-wellhausen.de/papers/Que ... ngine.html


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.