public SessionFactoryImpl(Configuration cfg, Settings settings) { this.settings = settings; //settings.CacheProvider.Start(null); #region Persisters entityPersisters = new Dictionary<string, IEntityPersister>(); foreach (ClassMetadata model in cfg.ClassMappings) { //string cacheRegion = model.EntityName; //ICacheConcurrencyStrategy cache; //if (!caches.TryGetValue(cacheRegion, out cache)) //{ // cache =CacheFactory.CreateCache(model.CacheConcurrencyStrategy, cacheRegion, model.IsMutable, settings, properties); // if (cache != null) // { // caches.Add(cacheRegion, cache); // } //} IEntityPersister cp = new EntityPersister(model, this); // PersisterFactory.CreateClassPersister(model, cache, this, mapping); entityPersisters[model.EntityName] = cp; } #endregion #region Serialization info name = settings.SessionFactoryName; uuid = Guid.NewGuid().ToString("N"); SessionFactoryObjectFactory.AddInstance(uuid, name, this); #endregion currentSessionContext = BuildCurrentSessionContext(); }
private Settings BuildSettings(SessionElement sessionElement) { Settings settings = new Settings(); IConnectionProvider connectionProvider = ConnectionProviderFactory.NewConnectionProvider(sessionElement); ITransactionFactory transactionFactory = CreateTransactionFactory(sessionElement); string releaseModeName = sessionElement.ConnectionReleaseMode; ConnectionReleaseMode releaseMode = "auto".Equals(releaseModeName) ? ConnectionReleaseMode.AfterTransaction : ParseConnectionReleaseMode(releaseModeName); settings.SessionFactoryName = sessionElement.Name; settings.ConnectionReleaseMode = releaseMode; // settings.DefaultBatchFetchSize = sessionElement.DefaultBatchFetchSize; settings.BatchSize = sessionElement.BatchSize; settings.BatcherFactory = new BatcherFactory();// CreateBatcherFactory(sessionElement, settings.BatchSize, connectionProvider); string isolationString = sessionElement.IsolationString; IsolationLevel isolation = IsolationLevel.Unspecified; if (isolationString.Length > 0) { try { isolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), isolationString); } catch { throw new Exception("The isolation level of " + isolationString + " is not a valid IsolationLevel. Please use one of the Member Names from the IsolationLevel."); } } settings.IsolationLevel = isolation; settings.ConnectionProvider = connectionProvider; settings.TransactionFactory = transactionFactory; return settings; }