@@ -15,7 +15,6 @@ namespace NHibernate.Loader
15
15
public class JoinWalker
16
16
{
17
17
private readonly ISessionFactoryImplementor factory ;
18
- private Queue < QueueEntry > joinQueue = new Queue < QueueEntry > ( ) ;
19
18
private int depth ;
20
19
protected readonly IList < OuterJoinableAssociation > associations = new List < OuterJoinableAssociation > ( ) ;
21
20
private readonly HashSet < AssociationKey > visitedAssociationKeys = new HashSet < AssociationKey > ( ) ;
@@ -33,6 +32,7 @@ public class JoinWalker
33
32
private string [ ] aliases ;
34
33
private LockMode [ ] lockModeArray ;
35
34
private SqlString sql ;
35
+ private readonly Queue < IJoinQueueEntry > _joinQueue = new ( ) ;
36
36
37
37
public string [ ] CollectionSuffixes
38
38
{
@@ -192,26 +192,11 @@ private void AddAssociationToJoinTree(IAssociationType type, string[] aliasedLhs
192
192
193
193
if ( qc != null )
194
194
{
195
- joinQueue . Enqueue (
196
- new CollectionQueueEntry ( )
197
- {
198
- Persister = qc ,
199
- Alias = subalias ,
200
- Path = path ,
201
- PathAlias = pathAlias ,
202
- }
203
- ) ;
195
+ _joinQueue . Enqueue ( new CollectionJoinQueueEntry ( qc , subalias , path , pathAlias ) ) ;
204
196
}
205
197
else if ( joinable is IOuterJoinLoadable jl )
206
198
{
207
- joinQueue . Enqueue (
208
- new EntityQueueEntry ( )
209
- {
210
- Persister = jl ,
211
- Alias = subalias ,
212
- Path = path ,
213
- }
214
- ) ;
199
+ _joinQueue . Enqueue ( new EntityJoinQueueEntry ( jl , subalias , path ) ) ;
215
200
}
216
201
}
217
202
@@ -327,9 +312,9 @@ protected void WalkCollectionTree(IQueryableCollection persister, string alias)
327
312
328
313
protected void ProcessJoins ( )
329
314
{
330
- while ( joinQueue . Count > 0 )
315
+ while ( _joinQueue . Count > 0 )
331
316
{
332
- QueueEntry entry = joinQueue . Dequeue ( ) ;
317
+ var entry = _joinQueue . Dequeue ( ) ;
333
318
entry . Walk ( this ) ;
334
319
}
335
320
}
@@ -466,7 +451,7 @@ protected virtual void WalkEntityTree(IOuterJoinLoadable persister, string alias
466
451
{
467
452
int n = persister . CountSubclassProperties ( ) ;
468
453
469
- joinQueue . Enqueue ( NextLevelQueueEntry . Instance ) ;
454
+ _joinQueue . Enqueue ( NextLevelJoinQueueEntry . Instance ) ;
470
455
for ( int i = 0 ; i < n ; i ++ )
471
456
{
472
457
IType type = persister . GetSubclassPropertyType ( i ) ;
@@ -1252,49 +1237,60 @@ protected static string GetSelectFragment(OuterJoinableAssociation join, string
1252
1237
return join . GetSelectFragment ( entitySuffix , collectionSuffix , next ) ;
1253
1238
}
1254
1239
1255
- protected abstract class QueueEntry
1240
+ protected interface IJoinQueueEntry
1256
1241
{
1257
- public abstract void Walk ( JoinWalker walker ) ;
1242
+ void Walk ( JoinWalker walker ) ;
1258
1243
}
1259
1244
1260
- protected abstract class QueueEntry < T > : QueueEntry where T : IJoinable
1245
+ protected class EntityJoinQueueEntry : IJoinQueueEntry
1261
1246
{
1262
- public string Alias { get ; set ; }
1263
- public T Persister { get ; set ; }
1264
- }
1247
+ private readonly IOuterJoinLoadable _persister ;
1248
+ private readonly string _alias ;
1249
+ private readonly string _path ;
1265
1250
1266
- protected abstract class EntityQueueEntry < T > : QueueEntry < T > where T : IJoinable
1267
- {
1268
- public string Path { get ; set ; }
1269
- }
1251
+ public EntityJoinQueueEntry ( IOuterJoinLoadable persister , string alias , string path )
1252
+ {
1253
+ _persister = persister ;
1254
+ _alias = alias ;
1255
+ _path = path ;
1256
+ }
1270
1257
1271
- protected class EntityQueueEntry : EntityQueueEntry < IOuterJoinLoadable >
1272
- {
1273
- public override void Walk ( JoinWalker walker )
1258
+ public void Walk ( JoinWalker walker )
1274
1259
{
1275
- walker . WalkEntityTree ( Persister , Alias , Path ) ;
1260
+ walker . WalkEntityTree ( _persister , _alias , _path ) ;
1276
1261
}
1277
1262
}
1278
1263
1279
- protected class CollectionQueueEntry : EntityQueueEntry < IQueryableCollection >
1264
+ protected class CollectionJoinQueueEntry : IJoinQueueEntry
1280
1265
{
1281
- public string PathAlias { get ; set ; }
1266
+ private readonly IQueryableCollection _persister ;
1267
+ private readonly string _alias ;
1268
+ private readonly string _path ;
1269
+ private readonly string _pathAlias ;
1270
+
1271
+ public CollectionJoinQueueEntry ( IQueryableCollection persister , string alias , string path , string pathAlias )
1272
+ {
1273
+ _persister = persister ;
1274
+ _alias = alias ;
1275
+ _path = path ;
1276
+ _pathAlias = pathAlias ;
1277
+ }
1282
1278
1283
- public override void Walk ( JoinWalker walker )
1279
+ public void Walk ( JoinWalker walker )
1284
1280
{
1285
- walker . WalkCollectionTree ( Persister , Alias , Path , PathAlias ) ;
1281
+ walker . WalkCollectionTree ( _persister , _alias , _path , _pathAlias ) ;
1286
1282
}
1287
1283
}
1288
1284
1289
- protected class NextLevelQueueEntry : QueueEntry
1285
+ protected class NextLevelJoinQueueEntry : IJoinQueueEntry
1290
1286
{
1291
- public static readonly NextLevelQueueEntry Instance = new NextLevelQueueEntry ( ) ;
1287
+ public static readonly NextLevelJoinQueueEntry Instance = new ( ) ;
1292
1288
1293
- private NextLevelQueueEntry ( )
1289
+ private NextLevelJoinQueueEntry ( )
1294
1290
{
1295
1291
}
1296
1292
1297
- public override void Walk ( JoinWalker walker )
1293
+ public void Walk ( JoinWalker walker )
1298
1294
{
1299
1295
walker . depth ++ ;
1300
1296
}
0 commit comments