-->
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.  [ 1 post ] 
Author Message
 Post subject: How to use multi-level, deep, fetch join in complex queries?
PostPosted: Thu Jun 26, 2008 9:26 am 
Newbie

Joined: Thu Jun 26, 2008 9:11 am
Posts: 2
Hi guys,
I'm pretty new to NHibernate, and I need some help. I'm using the latest release of NH, and I'm querying SQL Server 2005.

My tables and entities have the following structure:

Portal
....Id
....Names (Dictionary<string, string>)
....Settings (Dictionary<string, string>)
....Tabs (List<Tab>)
........Id
........Name
........Names (Dictionary<string, string>)
........Settings (Dictionary<string, string>)
........Modules (List<Module>)
............Id
............Name
............Settings (Dictionary<string, string>)
............Names (Dictionary<string, string>)

I'm trying to use a fetch-join query to get all the data in a single query, because I immediately need all data (I'll return it to the front-end server, via WCF). The query is as follows:

Portal p = hb.Session.CreateCriteria(typeof(Portal))
.Add(Expression.Eq("Id", Id))
.SetFetchMode("Tabs", FetchMode.Join)
.SetFetchMode("Settings", FetchMode.Join)
.SetFetchMode("Modules", FetchMode.Join)
.SetFetchMode("Names", FetchMode.Join)
.UniqueResult<Portal>();

What I noticed is the the Tabs and Modules child collections are filled immediately, while the Names and Settings collections are not, they are lazy loaded. Might it be that's because I have collections with the same names at various levels, and NHibernate doesn't know to which of them it should apply the fetch-join?

Can you suggest a way to run a single query and fill the entire data tree? Thanks a lot for your support.
Cheers,
- Marco


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

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.