-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix getting of initialized proxies for no-proxy associations outside of session scope #3347
Conversation
I see a test case that I don't understand. Not related to this change but about no-proxy nhibernate-core/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs Lines 126 to 139 in 4d29463
Why setting not initialized proxy leaves property initialized and do return proxy on property access. It doesn't look right to me. Setting not initialized proxy should mark property as not initialized and trigger entity initialization on property access returning unwrapped proxy. Any objections? |
Well, for simplicity, I guess, but also because user intend is not clear in such case, and yielding something else that what the user has affected could also be unexpected for the user. The user has mapped the Yielding an unwrapped proxy on subsequent get could cause some mess with the user own handled state: how can we ensure the user does no more hold any references to the original proxy? Now the same entity would be represented by two instances sent back to the user by the same session? That breaks one major contract of the session which strives very hard to always yield the same instance for an entity. So, better leave this in its current state in my opinion. |
He simply doesn't know it assigning some other lazy association. "order.Payment = invoice.Payment;" Also I see no restrictions on assigning proxy directly. From my understanding no-proxy just ensures to retrieve no proxy on property access (which is currently broken in case proxy is set by user)
Not sure I get it correctly. Did you mean proxy and unwrapped proxy? We already have such situation if proxy is loaded directly by user or with other entity before loading no-proxy owning entity: nhibernate-core/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs Lines 177 to 187 in 4d29463
Anyway, I'm not planning to fix it any time soon. Just a thought. |
Fixes #1267