http://nhforge.org/doc/nh/en/index.html#filters
<http://nhforge.org/doc/nh/en/index.html#filters> http://nhforge.org/doc/nh/en/index.html#performance-fetching-initialization (CreateFilter) On Mon, May 2, 2011 at 6:25 AM, Thomas JASKULA <[email protected]>wrote: > Hi, > > > > Let's say I have : > > > > class WebService > > { > > int IdWS {get; set; } > > IEnumerable<WebServiceOperation> Operations {get; set; } > > } > > > > class WebServiceOperations > > { > > int IdWebServiceOperation {get; set;} > > int IdWS {get; set; } > > IEnumerable<WebServiceOperation_Called> CalledOperations > {get; set;} > > } > > > > class WebServiceOperation_Called > > { > > int Id {get; set; } > > int IdWebServiceOperation {get; set; } > > int userId {get; set; } > > } > > > > Mappings are done WebService.IdWS = WebServiceOperations.IdWS and > WebServiceOperations. IdWebServiceOperation = WebServiceOperation_Called. > IdWebServiceOperation > > > > There will be always a WebService with at least one WebServiceOperation. > However there may be 0 or more WebServiceOperation_Called operations > depending on userId. > > > > So I would like to have CalledOperations collection empty or only with > items for a given user. > > > > I have this HQL : > > > > const string hql = @"select webservice from WebService as webservice left > outer join fetch webservice._operations as operations " + > > "left outer > join operations._calledOperations as calledOperations with > calledOperations._userId = :userId "; > > > > var ret = GetSession().CreateQuery(hql).SetInt32("userId", > userId).UniqueResult(); > > > > When debugging, generated SQL is correct. However in the resulting object I > have <WebServiceOperation_Called> CalledOperations collection populated with > data that doesn't take into account the 'with' restriction with > calledOperations._userId = :userId. I have all items where > WebServiceOperations. IdWebServiceOperation = WebServiceOperation_Called. > IdWebServiceOperation but it doesn't take into account the with keyword for > a given userId. > > > > I noticed that when acceding CalledOperations collection (which is lazy > loaded) NHibernate issues another query that populates the collection based > on the mapping without taking into account the with keyword. > > > > Maybe I'm doing it wrong. Do you see another solution to achieve it ? > > > > > > Thanks, > > > > Thomas > > -- > 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. > -- Fabio Maulo -- 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.
