-
Notifications
You must be signed in to change notification settings - Fork 933
Reconnect lazy property proxy on deserialization #1744
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
Reconnect lazy property proxy on deserialization #1744
Conversation
// Reconnect the lazy property proxies | ||
foreach (var p in entitiesByKey) | ||
{ | ||
if (p.Value is IFieldInterceptorAccessor lazyPropertyProxy && lazyPropertyProxy.FieldInterceptor != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractEntityPersister.AfterReassociate
does also this kind of things, but it is meant for detached entities and also handle dirtiness, which should be left untouched in the session deserialization case.
7323ddf
to
3a795fe
Compare
Text = "Text1" | ||
}; | ||
s.Save(se); | ||
_idSimpleEntity1 = se.Id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to write _idSimpleEntity1 = (Guid)s.Save(se);
. You can declare the _idSimpleEntity1
field as object and drop casting as the concrete type of the key does not matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to me as quite a matter of taste. I rather have two lines of code rather than a hard-coded cast. Granted, the test case does not need the exact typing of the id.
To be squashed.
After deserializing a session holding entities with uninitialized lazy properties, the lazy properties cannot be accessed because their proxy does no more have a session.
This is an old issue, independent of the used proxy factory. (Provided it is considered that proxies should not serialize their session, in order to avoid serializing the whole session when just serializing one entity.)