From: NHibernate J. <mik...@us...> - 2006-11-13 18:04:23
|
[ http://jira.nhibernate.org/browse/NH-473?page=all ] Sergey Koshcheyev updated NH-473: --------------------------------- Fix Version: LATER > order-by in <bag> is ignored if FetchMode is Join > ------------------------------------------------- > > Key: NH-473 > URL: http://jira.nhibernate.org/browse/NH-473 > Project: NHibernate > Type: Improvement > Components: Core > Versions: 1.0.1 > Reporter: Stefan Lieser > Fix For: LATER > > Given the following mapping: > <class name="Example.Book, Example" table="Books" > > <id name="Id" column="RecID" type="System.Int64" unsaved-value="0"> > <generator class="native" /> > </id> > <property name="Name" column="Name" type="System.String" /> > <bag name="Pages" lazy="true" order-by="PageNo" > > <key column="BookID" /> > <one-to-many class="Example.Page, Example" /> > </bag> > </class> > If I retrieve an object of class Book and let the Pages collection lazy load, everything is ok. The Pages collection is loaded on acces and ordered by PageNo: > ICriteria criteria = session.CreateCriteria(typeof(Book)); > criteria.Add(Expression.Eq("Name", name)); > Book book = criteria.UniqueResult() as Book; > ... > int count = book.Pages.Count; // collection is loaded with "order by PageNo" in the SQL statemenet > But if I retrieve the Book with FetchMode.Join on the Pages collection, the order-by is ignored: > ICriteria criteria = session.CreateCriteria(typeof(Book)); > criteria.Add(Expression.Eq("Name", name)); > criteria.SetFetchMode("Details", FetchMode.Join); > Book book = criteria.UniqueResult() as Book; // collection is loaded without "order by" in the SQL > Sincerely, > Stefan Lieser -- 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 |