Skip to content

Commit 2f1b4e4

Browse files
Iwanow, Mihail (EXT)fredericDelaporte
authored andcommitted
Mark methods without uncacheableCollections parameter as obsolete
1 parent b0fea9a commit 2f1b4e4

File tree

8 files changed

+86
-28
lines changed

8 files changed

+86
-28
lines changed

src/NHibernate/Async/Engine/Loading/CollectionLoadContext.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,24 @@ public partial class CollectionLoadContext
3333
/// complete.
3434
/// </summary>
3535
/// <param name="persister">The persister for which to complete loading. </param>
36-
/// <param name="uncacheableCollections">Indicates if collcetions can be put in cache</param>
36+
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
37+
[Obsolete("Please use EndLoadingCollections(ICollectionPersister, HashSet<string>) instead.")]
38+
public Task EndLoadingCollectionsAsync(ICollectionPersister persister, CancellationToken cancellationToken)
39+
{
40+
if (cancellationToken.IsCancellationRequested)
41+
{
42+
return Task.FromCanceled<object>(cancellationToken);
43+
}
44+
return EndLoadingCollectionsAsync(persister, null, cancellationToken);
45+
}
46+
47+
/// <summary>
48+
/// Finish the process of collection-loading for this bound result set. Mainly this
49+
/// involves cleaning up resources and notifying the collections that loading is
50+
/// complete.
51+
/// </summary>
52+
/// <param name="persister">The persister for which to complete loading. </param>
53+
/// <param name="uncacheableCollections">Indicates if collections can be put in cache</param>
3754
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
3855
public async Task EndLoadingCollectionsAsync(ICollectionPersister persister, HashSet<string> uncacheableCollections, CancellationToken cancellationToken)
3956
{
@@ -115,8 +132,11 @@ private async Task EndLoadingCollectionsAsync(ICollectionPersister persister, IL
115132
var cacheBatcher = new CacheBatcher(LoadContext.PersistenceContext.Session);
116133
for (int i = 0; i < count; i++)
117134
{
118-
await (EndLoadingCollectionAsync(matchedCollectionEntries[i], persister,
119-
data => cacheBatcher.AddToBatch(persister, data), uncacheableCollections, cancellationToken)).ConfigureAwait(false);
135+
await (EndLoadingCollectionAsync(
136+
matchedCollectionEntries[i],
137+
persister,
138+
data => cacheBatcher.AddToBatch(persister, data),
139+
uncacheableCollections, cancellationToken)).ConfigureAwait(false);
120140
}
121141
await (cacheBatcher.ExecuteBatchAsync(cancellationToken)).ConfigureAwait(false);
122142

@@ -126,8 +146,11 @@ private async Task EndLoadingCollectionsAsync(ICollectionPersister persister, IL
126146
}
127147
}
128148

129-
private async Task EndLoadingCollectionAsync(LoadingCollectionEntry lce, ICollectionPersister persister,
130-
Action<CachePutData> cacheBatchingHandler, HashSet<string> uncacheableCollections, CancellationToken cancellationToken)
149+
private async Task EndLoadingCollectionAsync(
150+
LoadingCollectionEntry lce,
151+
ICollectionPersister persister,
152+
Action<CachePutData> cacheBatchingHandler,
153+
HashSet<string> uncacheableCollections, CancellationToken cancellationToken)
131154
{
132155
cancellationToken.ThrowIfCancellationRequested();
133156
if (log.IsDebugEnabled())

src/NHibernate/Async/Loader/Criteria/CriteriaLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Task<IList> ListAsync(ISessionImplementor session, CancellationToken canc
3636
}
3737
try
3838
{
39-
return ListAsync(session, translator.GetQueryParameters(), querySpaces, cancellationToken);
39+
return ListAsync(session, translator.GetQueryParameters(), querySpaces, cancellationToken);
4040
}
4141
catch (Exception ex)
4242
{

src/NHibernate/Engine/Loading/CollectionLoadContext.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,19 @@ public IPersistentCollection GetLoadingCollection(ICollectionPersister persister
145145
/// complete.
146146
/// </summary>
147147
/// <param name="persister">The persister for which to complete loading. </param>
148-
/// <param name="uncacheableCollections">Indicates if collcetions can be put in cache</param>
148+
[Obsolete("Please use EndLoadingCollections(ICollectionPersister, HashSet<string>) instead.")]
149+
public void EndLoadingCollections(ICollectionPersister persister)
150+
{
151+
EndLoadingCollections(persister, null);
152+
}
153+
154+
/// <summary>
155+
/// Finish the process of collection-loading for this bound result set. Mainly this
156+
/// involves cleaning up resources and notifying the collections that loading is
157+
/// complete.
158+
/// </summary>
159+
/// <param name="persister">The persister for which to complete loading. </param>
160+
/// <param name="uncacheableCollections">Indicates if collections can be put in cache</param>
149161
public void EndLoadingCollections(ICollectionPersister persister, HashSet<string> uncacheableCollections)
150162
{
151163
if (!loadContexts.HasLoadingCollectionEntries && (localLoadingCollectionKeys.Count == 0))
@@ -224,8 +236,11 @@ private void EndLoadingCollections(ICollectionPersister persister, IList<Loading
224236
var cacheBatcher = new CacheBatcher(LoadContext.PersistenceContext.Session);
225237
for (int i = 0; i < count; i++)
226238
{
227-
EndLoadingCollection(matchedCollectionEntries[i], persister,
228-
data => cacheBatcher.AddToBatch(persister, data), uncacheableCollections);
239+
EndLoadingCollection(
240+
matchedCollectionEntries[i],
241+
persister,
242+
data => cacheBatcher.AddToBatch(persister, data),
243+
uncacheableCollections);
229244
}
230245
cacheBatcher.ExecuteBatch();
231246

@@ -235,8 +250,11 @@ private void EndLoadingCollections(ICollectionPersister persister, IList<Loading
235250
}
236251
}
237252

238-
private void EndLoadingCollection(LoadingCollectionEntry lce, ICollectionPersister persister,
239-
Action<CachePutData> cacheBatchingHandler, HashSet<string> uncacheableCollections)
253+
private void EndLoadingCollection(
254+
LoadingCollectionEntry lce,
255+
ICollectionPersister persister,
256+
Action<CachePutData> cacheBatchingHandler,
257+
HashSet<string> uncacheableCollections)
240258
{
241259
if (log.IsDebugEnabled())
242260
{

src/NHibernate/Engine/QueryParameters.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,22 @@ public QueryParameters(IType[] positionalParameterTypes, object[] postionalParam
4040
: this(positionalParameterTypes, postionalParameterValues, namedParameters, null, null, false, false, false, null, null, collectionKeys, null, null) {}
4141

4242
public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, LockMode> lockModes, RowSelection rowSelection,
43-
bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer)
43+
bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer)
4444
: this(positionalParameterTypes, positionalParameterValues, null, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer, null)
4545
{
4646
NaturalKeyLookup = isLookupByNaturalKey;
4747
}
4848

49+
[Obsolete("Please use QueryParameters(IDictionary<string, TypedValue>, IDictionary<string, LockMode>, " +
50+
"RowSelection, bool, bool, bool, string, string, bool, IResultTransformer, HashSet<string>) instead.")]
4951
public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized,
50-
bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer, HashSet<string> uncacheableCollections)
52+
bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer)
53+
: this(
54+
namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, isLookupByNaturalKey,
55+
transformer, null) {}
56+
57+
public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized,
58+
bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer, HashSet<string> uncacheableCollections)
5159
: this(
5260
TypeHelper.EmptyTypeArray, Array.Empty<object>(), namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null,
5361
transformer, uncacheableCollections)
@@ -56,9 +64,18 @@ public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDiction
5664
NaturalKeyLookup = isLookupByNaturalKey;
5765
}
5866

67+
[Obsolete("Please use QueryParameters(IType[], object[], IDictionary<string, TypedValue>, " +
68+
"IDictionary<string, LockMode>, RowSelection, bool, bool, bool, string, string, object[], IResultTransformer, HashSet<string>) instead.")]
5969
public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters,
60-
IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion,
61-
string comment, object[] collectionKeys, IResultTransformer transformer, HashSet<string> uncacheableCollections)
70+
IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion,
71+
string comment, object[] collectionKeys, IResultTransformer transformer)
72+
: this(
73+
TypeHelper.EmptyTypeArray, Array.Empty<object>(), namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null,
74+
transformer, null) {}
75+
76+
public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters,
77+
IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion,
78+
string comment, object[] collectionKeys, IResultTransformer transformer, HashSet<string> uncacheableCollections)
6279
{
6380
PositionalParameterTypes = positionalParameterTypes ?? Array.Empty<IType>();
6481
PositionalParameterValues = positionalParameterValues ?? Array.Empty<object>();
@@ -141,7 +158,7 @@ public bool HasRowSelection
141158
public bool Callable { get; set; }
142159

143160
/// <summary>
144-
/// Indicates if we can add loaded child collections to second lvl cache.
161+
/// Indicates if we can add loaded child collections to second level cache.
145162
/// </summary>
146163
public HashSet<string> UncacheableCollections { get; set; }
147164

src/NHibernate/Impl/CriteriaImpl.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string al
699699
this.joinType = joinType;
700700
this.withClause = withClause;
701701
JoinEntityName = joinEntityName;
702-
hasRestrictions = withClause != null;
702+
hasRestrictions = withClause != null;
703703

704704
root.subcriteriaList.Add(this);
705705

@@ -733,10 +733,10 @@ public string Path
733733
get { return path; }
734734
}
735735

736-
public bool HasRestrictions
737-
{
738-
get { return hasRestrictions; }
739-
}
736+
public bool HasRestrictions
737+
{
738+
get { return hasRestrictions; }
739+
}
740740

741741
public ICriteria Parent
742742
{
@@ -777,7 +777,7 @@ public ICriteria SetLockMode(LockMode lockMode)
777777

778778
public ICriteria Add(ICriterion expression)
779779
{
780-
hasRestrictions = true;
780+
hasRestrictions = true;
781781
root.Add(this, expression);
782782
return this;
783783
}

src/NHibernate/Loader/Criteria/CriteriaLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected override bool IsChildFetchEntity(int i)
9494

9595
public IList List(ISessionImplementor session)
9696
{
97-
return List(session, translator.GetQueryParameters(), querySpaces);
97+
return List(session, translator.GetQueryParameters(), querySpaces);
9898
}
9999

100100
protected override IResultTransformer ResolveResultTransformer(IResultTransformer resultTransformer)

src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,10 @@ private void CreateSubQuerySpaces()
922922

923923
var subQueries =
924924
rootCriteria.IterateExpressionEntries()
925-
.Select(x => x.Criterion)
926-
.OfType<SubqueryExpression>()
927-
.Select(x => x.Criteria)
928-
.OfType<CriteriaImpl>();
925+
.Select(x => x.Criterion)
926+
.OfType<SubqueryExpression>()
927+
.Select(x => x.Criteria)
928+
.OfType<CriteriaImpl>();
929929

930930
foreach (var criteriaImpl in subQueries)
931931
{

src/NHibernate/Loader/Loader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ internal void HandleEmptyCollections(object[] keys, object resultSetId, ISession
849849
if (Log.IsDebugEnabled())
850850
{
851851
Log.Debug("result set contains (possibly empty) collection: {0}",
852-
MessageHelper.CollectionInfoString(collectionPersisters[j], keys[i]));
852+
MessageHelper.CollectionInfoString(collectionPersisters[j], keys[i]));
853853
}
854854
session.PersistenceContext.LoadContexts.GetCollectionLoadContext((DbDataReader)resultSetId).GetLoadingCollection(
855855
collectionPersisters[j], keys[i]);

0 commit comments

Comments
 (0)