From: NHibernate J. <mik...@us...> - 2007-04-02 17:05:16
|
[ http://jira.nhibernate.org/browse/NH-805?page=comments#action_15397 ] Franz Meier commented on NH-805: -------------------------------- I saw that this features is partly implemented with the funktion SetFetchMode, but it is not alwaysworking: DetachedCriteria detachedCriteria; detachedCriteria = DetachedCriteria.For(typeof(TComponent)).Add(new NHibernate.Expression.EqExpression("ComponentId", m_obj.GetPrimaryKey)); detachedCriteria.SetFetchMode("HardwareComponents", NHibernate.FetchMode.Select); detachedCriteria.SetFetchMode("HardwareComponents.HardwareKey", NHibernate.FetchMode.Join); detachedCriteria.SetFetchMode("HardwareComponents.HardwareKey.PersonKey", NHibernate.FetchMode.Join); IList <TComponent> il = detachedCriteria.GetExecutableCriteria(this.session).List<TComponent>(); Console.WriteLine(((THardwareComponent)il[0].HardwareComponents[0]).HardwareKey.PersonKey.FirstName); Console.WriteLine(((THardwareComponent)il[0].HardwareComponents[1]).HardwareKey.PersonKey.FirstName); In my option this should result in: 1) on select to get the Tcomponent 2) on select to fetch the (THardwareComponent, THardware, TPerson) but it results in: 1) one select to get the tcomponent 2) one select to get the THardwareComponent 3) N selects to get the thardware,tperson components for each line in thardwarecomponent Is it so hard to implement this feature? I cannot understand the troubles, if the team does not like to implement this features, the please tell me and I will look myself for it. This is still the biggest problem of our projects, because we can only control the fechting stratety in the xml files, and thats not enough for different use cases. > A Function for setting the Fetch strategy on an Object > ------------------------------------------------------ > > Key: NH-805 > URL: http://jira.nhibernate.org/browse/NH-805 > Project: NHibernate > Type: New Feature > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Franz Meier > Fix For: LATER > > and a function to query collection later by specifying a fetching strategy > sample: > class User > { > string username; > Ilist UserGroups; > } > class UserGroup > { > User user; > Group group; > ... > } > class Group > { > string groupname; > IList UserGroups; > } > User user = session.Load<User>(1); > session.SetFetchingStrategy(user, "UserGroups", Strategy.Select) > session.SetFetchingStrategy(user, "UserGroups.group", Strategy.Join) > session.FetchCollection(user, "UserGroups"); // this funktion would the init the collection > // of the specified user object by using my defined fetching strategy > It think all funktion are available in the nhibernate core, somebody should only write > the funktions -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |