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
|