@@ -20,8 +20,8 @@ public partial class BulkOperationCleanupAction :
20
20
ICacheableExecutable
21
21
{
22
22
private readonly ISessionFactoryImplementor _factory ;
23
- private readonly HashSet < string > _affectedEntityNames = new HashSet < string > ( ) ;
24
- private readonly HashSet < string > _affectedCollectionRoles = new HashSet < string > ( ) ;
23
+ private readonly HashSet < string > _affectedEntityNames ;
24
+ private readonly HashSet < string > _affectedCollectionRoles ;
25
25
private readonly string [ ] _spaces ;
26
26
private readonly bool _hasCache ;
27
27
@@ -34,12 +34,22 @@ public BulkOperationCleanupAction(ISessionImplementor session, IQueryable[] affe
34
34
if ( queryables . HasCache )
35
35
{
36
36
_hasCache = true ;
37
+ if ( _affectedEntityNames == null )
38
+ {
39
+ _affectedEntityNames = new HashSet < string > ( ) ;
40
+ }
41
+
37
42
_affectedEntityNames . Add ( queryables . EntityName ) ;
38
43
}
39
44
40
45
var roles = _factory . GetCollectionRolesByEntityParticipant ( queryables . EntityName ) ;
41
46
if ( roles != null )
42
47
{
48
+ if ( _affectedCollectionRoles == null )
49
+ {
50
+ _affectedCollectionRoles = new HashSet < string > ( ) ;
51
+ }
52
+
43
53
_affectedCollectionRoles . UnionWith ( roles ) ;
44
54
}
45
55
@@ -70,12 +80,22 @@ public BulkOperationCleanupAction(ISessionImplementor session, ISet<string> quer
70
80
if ( persister . HasCache )
71
81
{
72
82
_hasCache = true ;
83
+ if ( _affectedEntityNames == null )
84
+ {
85
+ _affectedEntityNames = new HashSet < string > ( ) ;
86
+ }
87
+
73
88
_affectedEntityNames . Add ( persister . EntityName ) ;
74
89
}
75
90
76
91
var roles = session . Factory . GetCollectionRolesByEntityParticipant ( persister . EntityName ) ;
77
92
if ( roles != null )
78
93
{
94
+ if ( _affectedCollectionRoles == null )
95
+ {
96
+ _affectedCollectionRoles = new HashSet < string > ( ) ;
97
+ }
98
+
79
99
_affectedCollectionRoles . UnionWith ( roles ) ;
80
100
}
81
101
@@ -135,15 +155,15 @@ public void ExecuteAfterTransactionCompletion(bool success)
135
155
136
156
private void EvictCollectionRegions ( )
137
157
{
138
- if ( _affectedCollectionRoles != null && _affectedCollectionRoles . Any ( ) )
158
+ if ( _affectedCollectionRoles != null )
139
159
{
140
160
_factory . EvictCollection ( _affectedCollectionRoles ) ;
141
161
}
142
162
}
143
163
144
164
private void EvictEntityRegions ( )
145
165
{
146
- if ( _affectedEntityNames != null && _affectedEntityNames . Any ( ) )
166
+ if ( _affectedEntityNames != null )
147
167
{
148
168
_factory . EvictEntity ( _affectedEntityNames ) ;
149
169
}
0 commit comments