Which version ?
IIRC it was fixed.

On Wed, Aug 10, 2011 at 1:23 PM, Joseph Daigle <[email protected]>wrote:

> I believe I've discovered an issue with the new build-in proxy factory for
> NHibernate.
>
> If you have a proxy object which was created using ISession.Load<>(), then
> exceptions within NHibernate itself and the use of the NHibernate Profiler
> both will call ToString() on that proxy object. This results in an unwanted
> database look up for that entity.
>
> I've already reported this issue with the NHibernate Profiler team:
> https://groups.google.com/d/msg/nhprof/V_001ogMYC0/RVF0Ys5XQw4J
>
> The best way to demonstrate it is to do a test like this:
>
> session.CreateCriteria<Bar>().Add(Restrictions.Eq("FooReference",
> session.Load<Foo>(Guid.NewGuid()))).List();
>
> Assuming the correct database schema, one would expect this line of code to
> simply return an empty list. However if you have the NHibernate Profiler
> hooked up and execute this line of code, NHibernate will attempt will to
> load the instance of Foo (the profiler I think is calling  ToString() for
> its output). In this specific example, since the Id is random, it throws an
> exception.
>
> Additionally, if the above query generates an exception (for instance the
> database schema is wrong and the query cannot execute), NHibernate appears
> to call ToString() on the proxy object when generating the exception
> message. Which, again in this example, will cause a look up, which in turn
> throws an exception saying that the row does not exist.
>



-- 
Fabio Maulo

Reply via email to