コード例 #1
0
ファイル: SessionFactoryImpl.cs プロジェクト: PeterJee/vtms
        /// <summary>
        /// Closes the session factory, releasing all held resources.
        /// <list>
        /// <item>cleans up used cache regions and "stops" the cache provider.</item>
        /// <item>close the ADO.NET connection</item>
        /// </list>
        /// </summary>
        public void Close()
        {
            log.Info("Closing");

            isClosed = true;

            foreach (IEntityPersister p in entityPersisters.Values)
            {
                if (p.HasCache)
                {
                    p.Cache.Destroy();
                }
            }

            foreach (ICollectionPersister p in collectionPersisters.Values)
            {
                if (p.HasCache)
                {
                    p.Cache.Destroy();
                }
            }

            if (settings.IsQueryCacheEnabled)
            {
                queryCache.Destroy();

                foreach (IQueryCache cache in queryCaches.Values)
                {
                    cache.Destroy();
                }

                updateTimestampsCache.Destroy();
            }

            settings.CacheProvider.Stop();

            try
            {
                settings.ConnectionProvider.Dispose();
            }
            finally
            {
                SessionFactoryObjectFactory.RemoveInstance(uuid, name, properties);
            }

            if (settings.IsAutoDropSchema)
            {
                schemaExport.Drop(false, true);
            }

            eventListeners.DestroyListeners();
        }