Hey guys, i've been building a datalayer with NHibernate that has
default lazy = true for one to many collections.
but when i do a get by id on that same class i would like the
collections to be fetched immediately also.

The first solution i would want to have was to somehow find a way to
just change the lazy to false when catching a list, so i don't have to
change any of my mappings. everything was set to lazy = false.
Turns out this wasn't a possibillity? there is no way to set the lazy
binding except in the mapping.
Last week I found a post on the hibernate.org forum of how to do it in
Java but of course i didnt have any clue what the guy was talking
about. he was creating a new class that extended a Projection class. I
don't know which Projection class because since today that forum
doesn't seem to work anymore..
He created a NoJoinProjection class that he was using to add to the
criteria before getting the List.


After that i went to search to do it the other way around:
one to many collections were now set with lazy = true. now i don't
have to do anything special to fetch the lists, because they are
lazy.
They told me to use the criteria.SetFetchMode("OneToManyBagProperty",
FetchMode.Join);
of course my objects have more then one one to many collection so now
i'm getting the same items multiple times in my list, which - in a way
- is understandable..
crit.SetMaxResults does also not help because then i'll just get the
first item in the one to many list.


any solutions? I would like to use the first solution. that would be
the most easy for me to implement in my datalayer

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