private async Task EndLoadingCollectionAsync(LoadingCollectionEntry lce, ICollectionPersister persister, Action <CachePutData> cacheBatchingHandler, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (log.IsDebugEnabled()) { log.Debug("ending loading collection [{0}]", lce); } var persistenceContext = LoadContext.PersistenceContext; var session = persistenceContext.Session; bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); if (statsEnabled) { stopWath.Start(); } bool hasNoQueuedAdds = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization) if (persister.CollectionType.HasHolder()) { persistenceContext.AddCollectionHolder(lce.Collection); } CollectionEntry ce = persistenceContext.GetCollectionEntry(lce.Collection); if (ce == null) { ce = persistenceContext.AddInitializedCollection(persister, lce.Collection, lce.Key); } else { ce.PostInitialize(lce.Collection, persistenceContext); } bool addToCache = hasNoQueuedAdds && persister.HasCache && session.CacheMode.HasFlag(CacheMode.Put) && !ce.IsDoremove; // and this is not a forced initialization during flush if (addToCache) { await(AddCollectionToCacheAsync(lce, persister, cacheBatchingHandler, cancellationToken)).ConfigureAwait(false); } if (log.IsDebugEnabled()) { log.Debug("collection fully initialized: {0}", MessageHelper.CollectionInfoString(persister, lce.Collection, lce.Key, session)); } if (statsEnabled) { stopWath.Stop(); session.Factory.StatisticsImplementor.LoadCollection(persister.Role, stopWath.Elapsed); } }
private void EndLoadingCollection(LoadingCollectionEntry lce, ICollectionPersister persister) { if (log.IsDebugEnabled) { log.Debug("ending loading collection [" + lce + "]"); } ISessionImplementor session = LoadContext.PersistenceContext.Session; EntityMode em = session.EntityMode; bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); if (statsEnabled) { stopWath.Start(); } bool hasNoQueuedAdds = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization) if (persister.CollectionType.HasHolder(em)) { LoadContext.PersistenceContext.AddCollectionHolder(lce.Collection); } CollectionEntry ce = LoadContext.PersistenceContext.GetCollectionEntry(lce.Collection); if (ce == null) { ce = LoadContext.PersistenceContext.AddInitializedCollection(persister, lce.Collection, lce.Key); } else { ce.PostInitialize(lce.Collection); } bool addToCache = hasNoQueuedAdds && persister.HasCache && ((session.CacheMode & CacheMode.Put) == CacheMode.Put) && !ce.IsDoremove; // and this is not a forced initialization during flush if (addToCache) { AddCollectionToCache(lce, persister); } if (log.IsDebugEnabled) { log.Debug("collection fully initialized: " + MessageHelper.InfoString(persister, lce.Key, session.Factory)); } if (statsEnabled) { stopWath.Stop(); session.Factory.StatisticsImplementor.LoadCollection(persister.Role, stopWath.Elapsed); } }
/// <summary> add a collection we just pulled out of the cache (does not need initializing)</summary> public CollectionEntry AddInitializedCollection(ICollectionPersister persister, IPersistentCollection collection, object id) { CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing); ce.PostInitialize(collection); AddCollection(collection, ce, id); return ce; }
private void EndLoadingCollection( LoadingCollectionEntry lce, ICollectionPersister persister, Action <CachePutData> cacheBatchingHandler, bool skipCache) { if (log.IsDebugEnabled()) { log.Debug("ending loading collection [{0}]", lce); } var persistenceContext = LoadContext.PersistenceContext; var session = persistenceContext.Session; Stopwatch stopWatch = null; if (session.Factory.Statistics.IsStatisticsEnabled) { stopWatch = Stopwatch.StartNew(); } bool hasNoQueuedOperations = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization) if (persister.CollectionType.HasHolder()) { persistenceContext.AddCollectionHolder(lce.Collection); } CollectionEntry ce = persistenceContext.GetCollectionEntry(lce.Collection); if (ce == null) { ce = persistenceContext.AddInitializedCollection(persister, lce.Collection, lce.Key); } else { ce.PostInitialize(lce.Collection, persistenceContext); } bool addToCache = hasNoQueuedOperations && !skipCache && persister.HasCache && session.CacheMode.HasFlag(CacheMode.Put) && // and this is not a forced initialization during flush !ce.IsDoremove; if (addToCache) { AddCollectionToCache(lce, persister, cacheBatchingHandler); } if (!hasNoQueuedOperations) { lce.Collection.ApplyQueuedOperations(); } if (log.IsDebugEnabled()) { log.Debug("collection fully initialized: {0}", MessageHelper.CollectionInfoString(persister, lce.Collection, lce.Key, session)); } if (stopWatch != null) { stopWatch.Stop(); session.Factory.StatisticsImplementor.LoadCollection(persister.Role, stopWatch.Elapsed); } }
/// <summary> add a collection we just pulled out of the cache (does not need initializing)</summary> public CollectionEntry AddInitializedCollection(ICollectionPersister persister, IPersistentCollection collection, object id) { CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing); ce.PostInitialize(collection); collection.CollectionSnapshot = ce; // NH Different behavior AddCollection(collection, ce, id); return ce; }
/// <summary> /// add a collection we just pulled out of the cache (does not need initializing) /// </summary> /// <param name="collection"></param> /// <param name="persister"></param> /// <param name="id"></param> public CollectionEntry AddInitializedCollection( PersistentCollection collection, ICollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id, flushing ); ce.PostInitialize( collection ); collection.CollectionSnapshot = ce; AddCollection( collection, ce, id ); return ce; }