Skip to content

Commit 778d71d

Browse files
committed
Do not try to invalidate query spaces for non cached entities
Fixes #2129
1 parent ad19ece commit 778d71d

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

src/NHibernate/Action/BulkOperationCleanupAction.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ namespace NHibernate.Action
1414
/// Implementation of BulkOperationCleanupAction.
1515
/// </summary>
1616
[Serializable]
17-
public partial class BulkOperationCleanupAction : IAsyncExecutable, IAfterTransactionCompletionProcess
17+
public partial class BulkOperationCleanupAction :
18+
IAsyncExecutable,
19+
IAfterTransactionCompletionProcess,
20+
ICacheableExecutable
1821
{
1922
private readonly ISessionImplementor session;
2023
private readonly HashSet<string> affectedEntityNames = new HashSet<string>();
2124
private readonly HashSet<string> affectedCollectionRoles = new HashSet<string>();
2225
private readonly List<string> spaces;
26+
private readonly bool _hasCache;
2327

2428
public BulkOperationCleanupAction(ISessionImplementor session, IQueryable[] affectedQueryables)
2529
{
@@ -29,6 +33,7 @@ public BulkOperationCleanupAction(ISessionImplementor session, IQueryable[] affe
2933
{
3034
if (affectedQueryables[i].HasCache)
3135
{
36+
_hasCache = true;
3237
affectedEntityNames.Add(affectedQueryables[i].EntityName);
3338
}
3439
ISet<string> roles = session.Factory.GetCollectionRolesByEntityParticipant(affectedQueryables[i].EntityName);
@@ -65,6 +70,7 @@ public BulkOperationCleanupAction(ISessionImplementor session, ISet<string> quer
6570
{
6671
if (persister.HasCache)
6772
{
73+
_hasCache = true;
6874
affectedEntityNames.Add(persister.EntityName);
6975
}
7076
ISet<string> roles = session.Factory.GetCollectionRolesByEntityParticipant(persister.EntityName);
@@ -91,6 +97,8 @@ private bool AffectedEntity(ISet<string> querySpaces, string[] entitySpaces)
9197
return entitySpaces.Any(querySpaces.Contains);
9298
}
9399

100+
public bool HasCache => _hasCache;
101+
94102
#region IExecutable Members
95103

96104
public string[] PropertySpaces

src/NHibernate/Action/CollectionAction.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ namespace NHibernate.Action
1414
/// Any action relating to insert/update/delete of a collection
1515
/// </summary>
1616
[Serializable]
17-
public abstract partial class CollectionAction : IAsyncExecutable, IComparable<CollectionAction>, IDeserializationCallback, IAfterTransactionCompletionProcess
17+
public abstract partial class CollectionAction:
18+
IAsyncExecutable,
19+
IComparable<CollectionAction>,
20+
IDeserializationCallback,
21+
IAfterTransactionCompletionProcess,
22+
ICacheableExecutable
1823
{
1924
private readonly object key;
2025
[NonSerialized] private ICollectionPersister persister;
@@ -77,6 +82,8 @@ protected internal ISessionImplementor Session
7782
get { return session; }
7883
}
7984

85+
public bool HasCache => persister.HasCache;
86+
8087
#region IExecutable Members
8188

8289
/// <summary>

src/NHibernate/Action/EntityAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public abstract partial class EntityAction :
1818
IBeforeTransactionCompletionProcess,
1919
IAfterTransactionCompletionProcess,
2020
IComparable<EntityAction>,
21-
IDeserializationCallback
21+
IDeserializationCallback,
22+
ICacheableExecutable
2223
{
2324
private readonly string entityName;
2425
private readonly object id;
@@ -195,5 +196,7 @@ public void ExecuteAfterTransactionCompletion(bool success)
195196
{
196197
AfterTransactionCompletionProcessImpl(success);
197198
}
199+
200+
public bool HasCache => persister.HasCache;
198201
}
199202
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace NHibernate.Action
2+
{
3+
//6.0 TODO: Merge to IExecutable
4+
public interface ICacheableExecutable : IExecutable
5+
{
6+
bool HasCache { get; }
7+
}
8+
}

src/NHibernate/Async/Action/BulkOperationCleanupAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
namespace NHibernate.Action
2222
{
23-
public partial class BulkOperationCleanupAction : IAsyncExecutable, IAfterTransactionCompletionProcess
23+
public partial class BulkOperationCleanupAction :
24+
IAsyncExecutable,
25+
IAfterTransactionCompletionProcess,
26+
ICacheableExecutable
2427
{
2528

2629
#region IExecutable Members

src/NHibernate/Async/Action/CollectionAction.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ namespace NHibernate.Action
2222
{
2323
using System.Threading.Tasks;
2424
using System.Threading;
25-
public abstract partial class CollectionAction : IAsyncExecutable, IComparable<CollectionAction>, IDeserializationCallback, IAfterTransactionCompletionProcess
25+
public abstract partial class CollectionAction:
26+
IAsyncExecutable,
27+
IComparable<CollectionAction>,
28+
IDeserializationCallback,
29+
IAfterTransactionCompletionProcess,
30+
ICacheableExecutable
2631
{
2732

2833
protected async Task<object> GetKeyAsync(CancellationToken cancellationToken)

src/NHibernate/Async/Action/EntityAction.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public abstract partial class EntityAction :
2525
IBeforeTransactionCompletionProcess,
2626
IAfterTransactionCompletionProcess,
2727
IComparable<EntityAction>,
28-
IDeserializationCallback
28+
IDeserializationCallback,
29+
ICacheableExecutable
2930
{
3031

3132
#region IExecutable Members

src/NHibernate/Engine/ActionQueue.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ private void RegisterCleanupActions(IExecutable executable)
216216
RegisterProcess(executable.AfterTransactionCompletionProcess);
217217
#pragma warning restore 618,619
218218
}
219-
if (executable.PropertySpaces != null)
219+
220+
if (executable.PropertySpaces != null && (!(executable is ICacheableExecutable ce) || ce.HasCache))
220221
{
221222
executedSpaces.UnionWith(executable.PropertySpaces);
222223
}

0 commit comments

Comments
 (0)