/// <summary> called by a collection that wants to initialize itself</summary> public virtual void OnInitializeCollection(InitializeCollectionEvent @event) { IPersistentCollection collection = @event.Collection; ISessionImplementor source = @event.Session; CollectionEntry ce = source.PersistenceContext.GetCollectionEntry(collection); if (ce == null) throw new HibernateException("collection was evicted"); if (!collection.WasInitialized) { if (log.IsDebugEnabled) { log.Debug("initializing collection " + MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, source.Factory)); } log.Debug("checking second-level cache"); bool foundInCache = InitializeCollectionFromCache(ce.LoadedKey, ce.LoadedPersister, collection, source); if (foundInCache) { log.Debug("collection initialized from cache"); } else { log.Debug("collection not cached"); ce.LoadedPersister.Initialize(ce.LoadedKey, source); log.Debug("collection initialized"); if (source.Factory.Statistics.IsStatisticsEnabled) { source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role); } } } }
public override Task OnInitializeCollectionAsync(InitializeCollectionEvent @event, CancellationToken cancellationToken) { var result = base.OnInitializeCollectionAsync(@event, cancellationToken); AddEvent(@event, this); return(result); }
/// <summary> called by a collection that wants to initialize itself</summary> public virtual async Task OnInitializeCollectionAsync(InitializeCollectionEvent @event, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); IPersistentCollection collection = @event.Collection; ISessionImplementor source = @event.Session; bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); if (statsEnabled) { stopWath.Start(); } CollectionEntry ce = source.PersistenceContext.GetCollectionEntry(collection); if (ce == null) { throw new HibernateException("collection was evicted"); } if (!collection.WasInitialized) { if (log.IsDebugEnabled()) { log.Debug("initializing collection {0}", MessageHelper.CollectionInfoString(ce.LoadedPersister, collection, ce.LoadedKey, source)); } log.Debug("checking second-level cache"); bool foundInCache = await(InitializeCollectionFromCacheAsync(ce.LoadedKey, ce.LoadedPersister, collection, source, cancellationToken)).ConfigureAwait(false); if (foundInCache) { log.Debug("collection initialized from cache"); } else { log.Debug("collection not cached"); await(ce.LoadedPersister.InitializeAsync(ce.LoadedKey, source, cancellationToken)).ConfigureAwait(false); log.Debug("collection initialized"); if (statsEnabled) { stopWath.Stop(); source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role, stopWath.Elapsed); } } } }
/// <summary> called by a collection that wants to initialize itself</summary> public virtual void OnInitializeCollection(InitializeCollectionEvent @event) { IPersistentCollection collection = @event.Collection; ISessionImplementor source = @event.Session; bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); if (statsEnabled) { stopWath.Start(); } CollectionEntry ce = source.PersistenceContext.GetCollectionEntry(collection); if (ce == null) { throw new HibernateException("collection was evicted"); } if (!collection.WasInitialized) { if (log.IsDebugEnabled) { log.Debug("initializing collection " + MessageHelper.CollectionInfoString(ce.LoadedPersister, collection, ce.LoadedKey, source)); } log.Debug("checking second-level cache"); bool foundInCache = InitializeCollectionFromCache(ce.LoadedKey, ce.LoadedPersister, collection, source); if (foundInCache) { log.Debug("collection initialized from cache"); } else { log.Debug("collection not cached"); ce.LoadedPersister.Initialize(ce.LoadedKey, source); log.Debug("collection initialized"); if (statsEnabled) { stopWath.Stop(); source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role, stopWath.Elapsed); } } } }
public override void OnInitializeCollection(InitializeCollectionEvent @event) { base.OnInitializeCollection(@event); AddEvent(@event, this); }
public override async Task OnInitializeCollectionAsync(InitializeCollectionEvent @event, CancellationToken cancellationToken) { await(base.OnInitializeCollectionAsync(@event, cancellationToken)); AddEvent(@event, this); }
public void OnInitializeCollection(InitializeCollectionEvent @event) { log.Debug("OnInitializeCollection :" + @event); }