-
Notifications
You must be signed in to change notification settings - Fork 931
Fix ISession.Refresh not updating initialized lazy properties #3697
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
Changes from 4 commits
5ecf1d6
ffc8a79
7364a96
307e602
73c33c6
8cfda99
4227bf0
21359b2
bf0ee3b
677a63c
c4dbd29
f620558
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Iesi.Collections.Generic; | ||
using NHibernate.Engine; | ||
using NHibernate.Persister.Entity; | ||
|
@@ -21,7 +22,8 @@ public abstract class AbstractFieldInterceptor : IFieldInterceptor | |
private readonly HashSet<string> loadedUnwrapProxyFieldNames = new HashSet<string>(); | ||
private readonly string entityName; | ||
private readonly System.Type mappedClass; | ||
|
||
private readonly string[] originalUninitializedFields; | ||
|
||
[NonSerialized] | ||
private bool initializing; | ||
private bool isDirty; | ||
|
@@ -33,7 +35,8 @@ protected internal AbstractFieldInterceptor(ISessionImplementor session, ISet<st | |
this.unwrapProxyFieldNames = unwrapProxyFieldNames ?? new HashSet<string>(); | ||
this.entityName = entityName; | ||
this.mappedClass = mappedClass; | ||
this.uninitializedFieldsReadOnly = uninitializedFields != null ? new ReadOnlySet<string>(uninitializedFields) : null; | ||
this.uninitializedFieldsReadOnly = uninitializedFields != null ? new ReadOnlySet<string>(new HashSet<string>(uninitializedFields)) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a bug that ReadOnlySet is not really read-only It was possible to update content of read-only set by updating underlying collection. Some tests were depend on that behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely an improvement, but I'd like to know more before I change it. So I added an extra variable. |
||
this.originalUninitializedFields = uninitializedFields != null ? uninitializedFields.ToArray() : null; | ||
} | ||
|
||
#region IFieldInterceptor Members | ||
|
@@ -207,7 +210,18 @@ private object InitializeField(string fieldName, object target) | |
|
||
public ISet<string> GetUninitializedFields() | ||
{ | ||
return uninitializedFieldsReadOnly ?? CollectionHelper.EmptySet<string>(); | ||
return uninitializedFields ?? CollectionHelper.EmptySet<string>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to return |
||
} | ||
|
||
public void ClearInitializedLazyFields() | ||
{ | ||
if (this.originalUninitializedFields == null) | ||
return; | ||
|
||
foreach (var originalUninitializedField in this.originalUninitializedFields) | ||
{ | ||
this.uninitializedFields.Add(originalUninitializedField); | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
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 seems to be same as
uninitializedFieldsReadOnly