Done: https://nhibernate.jira.com/browse/NH-2834

In doing more research I actually discovered this "bug" is really the result 
of relying on Castle's behavior when handling proxies. Prior to 3.1 LinFu 
actually behaves the same way that the new DefaultProxyFactory in 3.2 
behaves; in that it intercepts calls to ToString() sent to the base object 
class and forces the proxy to initialize.

I personally think that the proxy should only be initialized for ToString() 
methods if the mapped class overrides ToString(), much in the same way the 
Equals() and GetHashCode() behave. So I submitted a patch which introduces 
that same behavior. If ToString() is not overridden on the proxy, then 
simply return the class name. Otherwise fall through the default behavior 
for initializing the proxy.

ToString() is one of those methods which is very easy to call without 
explicitly calling it. Passing an object into code that, for example, 
generates exception messages or logs will likely call ToString() somewhere, 
which can have unintended side-effects. Such as an extra database query.

-- 
Joseph Daigle

Reply via email to