Hi there,
I have a very complicated object model/database - when I try to load the entity that's at the top of the tree (using session.load) I can see 4000+ lines of sql being generated. I have tried to tune this using fetch="join" on the main offending collection - this attempts to join but the query is then too complex.
When I set this back to "select" mode however, then change some of the descendant collections to use fetch="join", this seems to be ignored. I have tried to be more fine grained using the criteria objects and setting the FetchMode, more or less as follows:
Code:
ICriteria criteria = session.CreateCriteria(typeof (Parent));
criteria.Add(Expression.Eq("ParentID"), 12345));
criteria.CreateCriteria("ChildCollection1").SetFetchMode("ChildCollection2", FetchMode.EAGER);
criteria.SetResultTransformer(CriteriaUtil.DistinctRootEntity);
Parent result = (Parent) criteria.UniqueResult();
... but because I'm using 'createcriteria' on the first collection it automatically tries to use a join (I have also tried specifying the JoinType.None).... ChildCollection2 is mapped using fetch="join" but as described in the 1st scenario, this seems to be ignored...
Can anybody help please?
Thanks in anticipation, Carl