Hi All.
I have a problem. If my instances was loaded previously via some relation by the NHibernate session and I get to a lazy collection where the same instance is referenced to, after initializating my collection contains the proxy object instead of the originally created object.
As far as I can figure out I only have 1 Session. Since I do not close the session and I only request 1 session ever from the sessionfactory. From the reference manual:
Quote:
This only applies if these objects are loaded in two different ISessions, as NHibernate only guarantees identity
( a == b , the default implementation of Equals()) inside a single ISession!
I tried to overide GetHashCode and Equals in my objects, I use a hash of a Guid on the object
which is not the key . As stated in the manual.
Why am I always getting the CProxy type object if it was loaded before? Is this the normal behaviour ? Is it possible to make NHibernate always return the entity instance.
There is a similar problem discussion on
http://forum.hibernate.org/viewtopic.php?t=972826&highlight=cproxytype
The reason I do not want to work with the proxy object is that the software I wrote does not like it. I would much rather try and solve the problem at the loading part than try to work around it.
I am using NHibernate 1.2.0.GA with Attribute mappings.
Also my Proxy is not interface type but sits on the class itself.
Thanks in advance.