Fixing OutOfMemory exception when using PrepareSql

The PrepareSql is defined only for Sql Server right now, using
a new steps DateServiceProviders to customize nhibernate
properties.

Work Items: 20563, 20550
This commit is contained in:
Sebastien Ros
2014-03-17 11:31:03 -07:00
parent 94011c8944
commit da6a636247
2 changed files with 13 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using FluentNHibernate;
using FluentNHibernate.Automapping;
@@ -48,7 +47,6 @@ namespace Orchard.Data.Providers {
.SetProperty(NHibernate.Cfg.Environment.FormatSql, Boolean.FalseString)
.SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, Boolean.FalseString)
.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, Hbm2DDLKeyWords.None.ToString())
.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString)
.SetProperty(NHibernate.Cfg.Environment.PropertyBytecodeProvider, "lcg")
.SetProperty(NHibernate.Cfg.Environment.PropertyUseReflectionOptimizer, Boolean.TrueString)
.SetProperty(NHibernate.Cfg.Environment.QueryStartupChecking, Boolean.FalseString)
@@ -62,6 +60,10 @@ namespace Orchard.Data.Providers {
cfg.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[0];
cfg.EventListeners.PreLoadEventListeners = new IPreLoadEventListener[0];
// don't enable PrepareSql by default as it breaks on SqlCe
// this can be done per driver by overriding AlterConfiguration
AlterConfiguration(cfg);
parameters.Configurers.Invoke(c => c.Building(cfg), Logger);
})
@@ -72,6 +74,10 @@ namespace Orchard.Data.Providers {
return config.BuildConfiguration();
}
protected virtual void AlterConfiguration(Configuration config) {
}
public static AutoPersistenceModel CreatePersistenceModel(ICollection<RecordBlueprint> recordDescriptors) {
if(recordDescriptors == null) {
throw new ArgumentNullException("recordDescriptors");

View File

@@ -1,5 +1,6 @@
using System;
using FluentNHibernate.Cfg.Db;
using NHibernate.Cfg;
using NHibernate.SqlAzure;
namespace Orchard.Data.Providers {
@@ -32,5 +33,9 @@ namespace Orchard.Data.Providers {
return persistence;
}
protected override void AlterConfiguration(Configuration config) {
config.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString);
}
}
}