Hi, Can someone explain to me why I saw this behaviour with NH 2.0.1GA?
All objects have virtual properties and methods and use Lazy Loading. 1) Load object A via Get(id). Object has a many-to-one mapping to object B but object B is lazy loaded. Object A also happens to have a set of object B's, also lazy loaded. Check object A through debugger - object B many-to-one reference is correctly set to an NH proxy class, as is the set. 2) Run a seperate HQL query to get all object B's for an object A. We happen to chose the same object A that is already loaded in the NH session. Check the returned list through debugger. The collection has (e.g.) 5 elements. The first element is of value object B but is of type NH proxy (i.e. its the same object as is also mapped to object A through the many-to-one). The other 4 elements are of value object B and type object B (i.e. NH has loaded all the objects, but not replaced the original proxy with an actual instance of object B). Can someone explain why this is the case? Shouldn't the HQL query replace the proxies in the session cache with the real objects? Its an issue because I then bind the result to a gridview and it fails as the first object in the list is different to the rest of the objects. I thought I could fix it by using a custom collection that implemented ITypedList but this simply moves the error from a "object" reference problem to a "property" reference problem. I've got round it by turning lazy loading off for the object A -> object B many-to-one relationship, but its far from ideal. I'd like to understand what NH is doing and why... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
