If so, in your fluent mappings .. Where you have .lazyload(..) make it
.Not.LazyLoad(..)
On 9/29/11, Gunnar Liljas <gunnar...@gmail.com> wrote:
> Make the assertion..
>
> Assert.IsInstanceOf<Bar>(foo.Bar);
>
> instead.
>
> The "no-proxy" setting does not imply that the loaded instance will
> not *be*a proxy. It implies that it will
> *not be loaded using* a proxy. That's a big difference, especially in
> polymorphic associations.
>
> That said, the behavior is still a bit strange, since the assertion fails if
> sub properties are accessed before it.
>
> Hmmm....investigating.
>
> /G
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
--
Sent from my mobile device
------
Joe Brockhaus
joe.br...@gmail.com
------------
I have yet to upgrade from 3.1 using fluent as well .. I'll have to
experiment w/ this some more myself. Thx for headsup. If i find
anything i'll letcha know.
var foo = session.Get<Foo>(10);
var bars = session.CreateCriteria<Bar>().List<Bar>();
If the first example loads foo and foo.Bar as a proxy and the same
session is then used again in example 2 it can cause an exception. The
criteria query will return all bar classes but will resolve things out
of the session if it can. This means the bar which was proxied for the
first query and put in the session will be resolved. When it comes to
the List<Bar> an exception will occur as you cannot put
INhibernateProxyProxy into the a list of type Bar.
I experienced this issue yesterday, the only two solutions I can think
of are:
1 - use session.CreateCriteria<Bar>().List() so untyped values are
returned. An extension method can be made to allow each element to be
unproxied (I can't remember the NHibernate API method for this) and
turned into a generic list of the given type.
2 - Don't use proxies. For me it is very unattractive to have to mark
all properties AND methods virtual. If a class hierarchy exists then
it very hard to understand what can and can't be overridden. It also
means any class can be inherited from and fudged by someone else. This
is not a big problem if you are working on a small application on your
own or with one other person but if you are in a large team building
relatively large software then to me this is a big deal. But it seems
that the proxy support has not been entirely thought out. There are
issues I also get with lazy / eager loading and I wonder what other
issues I will encounter.
On Oct 25, 2:48 pm, Joseph Lam <jla...@gmail.com> wrote:
> This seems related:https://nhibernate.jira.com/browse/NH-2845