If you want something really special there is lazy="extra" btw map
Country.Address where the country is something else than 'San Marino' or
'Cittá del Vaticano' is not acceptable.

2009/8/12 Chris Browne <[email protected]>

>
> well it looks like i'm going to have to rethink the domain model!
> i'm going to follow the rule of thumb and see if i can manage this
> collection in a different manor.
>
> but the fact still remains that NH is loading this child collection in
> a very un-lazy way. i'm not accessing it at all and it is still
> loading it.
>
> is this expected behaviour?!
>
> chris.
>
>
> On Aug 12, 4:03 am, Fabio Maulo <[email protected]> wrote:
> > The rule of thumbs is:don't map a collection if you can't work with
> > lazy=false.
> >
> > 2009/8/12 Fabio Maulo <[email protected]>
> >
> >
> >
> > > as you said "MASSIVE"... lookCountry has as child State that has as
> child
> > > City that has as child Streets that has as child Address, in an Address
> > > there living people and Person.
> > > The country is China.
> >
> > > Try to upload the Country with lazy=false.
> >
> > > What I mean is that you having a completely wrong domain design.
> >
> > > 2009/8/11 Chris Browne <[email protected]>
> >
> > >> hi guys,
> >
> > >> i've got strange problem that i'm hoping is just down to my
> > >> inexperience with NH...
> >
> > >> i asked this question on stackoverflow:
> >
> > >>http://stackoverflow.com/questions/1244995/partially-populate-child-c.
> ..
> > >> and learnt that it is by design that NH lazy loads the entire child
> > >> collection when you itterate over it, regardless of a supplied
> > >> restriction (in this case i only want child objects with a certain
> > >> date).
> >
> > >> so the recomendation was to just load the parent object, then
> > >> separately query for the filtered children i wanted, then associate
> > >> them.
> >
> > >> so i've tried that, and it looks to be a winner, except, what ever i
> > >> do, NH keeps hitting the Db and fully populating the child collection,
> > >> even though its lazy loaded, and i'm not iterating over it.
> >
> > >> very annoying.
> >
> > >> what i want to do is something like the following:
> >
> > >>        var post = session.CreateCriteria<BlogPost>()
> > >>            .Add(Restrictions.Eq("Id", 1))
> > >>            .UniqueResult<BlogPost>();
> >
> > >>        var comments = session.CreateCriteria<Comment>()
> > >>            .Add(Restrictions.Eq("BlogPostId", 1))
> > >>            .Add(Restrictions.Eq("DatePosted", new DateTime(2009, 8,
> > >> 1)))
> > >>            .List<Comment>();
> >
> > >>        post.Comments = comments;
> >
> > >> but running this bit of code with Sql Profilier running shows that 3
> > >> queries get sent to the database, the first one is to get the single
> > >> post (good) when the fist statement gets executed, and when the second
> > >> statement gets executed, we get two queries sent to the Db, the first
> > >> of these is to get the filtered list of comments (good!), but then
> > >> another is sent to get the entire list of comments (bad!).
> >
> > >> the example i've got here is not the domain my project is in. in the
> > >> real domain the child collection is MASSIVE, and would never be
> > >> queried without a filter on the date, so i REALLY dont want the whole
> > >> lot coming back!
> >
> > >> has anyone got any ideas?
> >
> > >> cheers,
> > >> chris.
> >
> > > --
> > > Fabio Maulo
> >
> > --
> > Fabio Maulo
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to