示例#1
0
		/// <summary>
		/// Called by the framework to initialize the persistent store.
		/// </summary>
		public void Initialize()
		{
			Platform.Log(LogLevel.Info, "Initializing NHibernate subsystem...");

			// create the hibernate configuration
			_cfg = new Configuration();

			// this will automatically read from the app.config
			_cfg.Configure();

			Platform.Log(LogLevel.Debug, "NHibernate connection string: {0}", this.ConnectionString);

			// add each assembly to the hibernate configuration
			// this tells NHibernate to look for .hbm.xml embedded resources in these assemblies
			// TODO: we should only scan plugins that are tied to this PersistentStore, but there is currently no way to know this
			var orderer = new AssembliesHbmOrderer(Platform.PluginManager.Plugins);
			orderer.AddToConfiguration(_cfg);

			// setup default caching strategies for all classes/collections that don't have one explicitly
			// specified in the mapping files
			CreateDefaultCacheStrategies();

			// create the session factory
			_sessionFactory = _cfg.BuildSessionFactory();

			Platform.Log(LogLevel.Info, "NHibernate initialization complete.");
		}
示例#2
0
        /// <summary>
        /// Called by the framework to initialize the persistent store.
        /// </summary>
        public void Initialize()
        {
            Platform.Log(LogLevel.Info, "Initializing NHibernate subsystem...");

            // create the hibernate configuration
            _cfg = new Configuration();

            // this will automatically read from the app.config
            _cfg.Configure();

            Platform.Log(LogLevel.Debug, "NHibernate connection string: {0}", this.ConnectionString);

            // add each assembly to the hibernate configuration
            // this tells NHibernate to look for .hbm.xml embedded resources in these assemblies
            // TODO: we should only scan plugins that are tied to this PersistentStore, but there is currently no way to know this
            var orderer = new AssembliesHbmOrderer(Platform.PluginManager.Plugins);

            orderer.AddToConfiguration(_cfg);

            // setup default caching strategies for all classes/collections that don't have one explicitly
            // specified in the mapping files
            CreateDefaultCacheStrategies();

            // create the session factory
            _sessionFactory = _cfg.BuildSessionFactory();

#if DEBUG
            if (PersistentStoreProfilerSettings.Default.Enabled)
            {
                InitializeProfiler();
            }
#endif

            Platform.Log(LogLevel.Info, "NHibernate initialization complete.");
        }