If you have to access deep object graphs, I suggest reading:Efficently loading deep object graphs<http://ayende.com/Blog/archive/2007/06/20/Efficently-loading-deep-object-graphs.aspx> And Working with deep object graphs and NHibernate<http://ayende.com/Blog/archive/2006/10/05/WorkingWithDeepObjectGraphsAndNHibernate.aspx> On Tue, Feb 17, 2009 at 12:22 AM, Vladan Strigo <[email protected]> wrote:
> > But how does that solve the recursive groups problem? > > I don't have a problem loading Articles of a given Group which are > filter with a Where, but I have a problem loading all the related > groups because of the non-limited recursion. What I end up is > basically like there was no Where condition at all, because NH loads > all the children of groups (although it has an appropriate set of > Articles already loaded) when doing a foreach (which is kind of > expected). > > I've even tried when doing a recursive foreach to check if a proxy has > been loaded (to stop it from loading by checking and proceeding if it > wasnt), but as it seems in that case, all the child collections are > not loaded :( > > > Maybe I didn't understand you correctly Ayende? > > > Thanks, > Vladan > > On Feb 16, 2:59 am, Ayende Rahien <[email protected]> wrote: > > Create a BreakingArticles collection that would have a where on itforce > > eager load of that. > > > > On Sun, Feb 15, 2009 at 6:13 PM, Vladan Strigo <[email protected]> > wrote: > > > > > Hi, > > > > > I have an interesting case... > > > > > I have a Group entity which can be nested (think parent groups which > > > can have children groups). > > > A Group can hold Articles (one to many) > > > An Article has a Type (Normal, Breaking, etc...) > > > > > Now...I want to make a query to get me the complete object graph for a > > > certain article type...say that the use case is...show a grouped list > > > of all "breaking" articles. > > > > > My initial idea was to make this into a multi query: > > > 1st query --> get all Groups (there will be max 20 groups > > > ALWAYS...unbound set is very unlikely to happen) > > > 2nd query --> get all Articles by Article type "Breaking" > > > > > NHibernate's engine would tie the references together, and with a > > > simple and effective query I could easily show the complete structure > > > of Groups (nesting levels are not limited), along with their belonging > > > Articles. > > > > > It does work...however... > > > > > As I later do a "foreach" on the groups to show the structure, NH goes > > > to Lazy load the missing articles from the DB (ones not retreived by > > > 2nd query in Multi query), which is not exactly what I want. > > > > > ...One natural solution would be to write the 1st query with > > > Restrictions to load only the Groups with Articles of a given Type, > > > but that would be simple if the groups were not nested (just add alias > > > and a join and of you go...). However, as Group nesting is not > > > limited, I am not sure if that kind of query can be written in NH. > > > Query put in words...give me all the Groups which have an Article of a > > > given type, or have a Child Group which has such an Article, or which > > > has a Child's Child Group...(as you can imagine, the recursion can go > > > on)... > > > > > ...Other solution would be to tell NH somehow...what I've loaded so > > > far is IT. Don't load anything else later, and don't load anything > > > more now, other than what I told you to...which basically > > > means...disable both eager and lazy loading... > > > > > I am not sure if I've explained the issue with enough detail, please > > > ask if I haven't. > > > > > Anyone has a clue where to start? > > > > > Thank you! > > > > > Vladan Strigo > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
