@@ -1288,6 +1288,7 @@ protected virtual void ConfigureProxyFactoryFactory()
1288
1288
1289
1289
#endregion
1290
1290
}
1291
+
1291
1292
/// <summary>
1292
1293
/// Instantiate a new <see cref="ISessionFactory" />, using the properties and mappings in this
1293
1294
/// configuration. The <see cref="ISessionFactory" /> will be immutable, so changes made to the
@@ -1296,17 +1297,33 @@ protected virtual void ConfigureProxyFactoryFactory()
1296
1297
/// <returns>An <see cref="ISessionFactory" /> instance.</returns>
1297
1298
public ISessionFactory BuildSessionFactory ( )
1298
1299
{
1300
+ var dynamicDialectMapping = mapping ;
1301
+ // Use a mapping which does store the dialect instead of instantiating a new one
1302
+ // at each access. The dialect does not change while building a session factory.
1303
+ // It furthermore allows some hack on NHibernate.Spatial side to go on working,
1304
+ // See nhibernate/NHibernate.Spatial#104
1305
+ mapping = new StaticDialectMappingWrapper ( mapping ) ;
1306
+ try
1307
+ {
1308
+ ConfigureProxyFactoryFactory ( ) ;
1309
+ SecondPassCompile ( ) ;
1310
+ Validate ( ) ;
1311
+ Environment . VerifyProperties ( properties ) ;
1312
+ Settings settings = BuildSettings ( ) ;
1299
1313
1300
- ConfigureProxyFactoryFactory ( ) ;
1301
- SecondPassCompile ( ) ;
1302
- Validate ( ) ;
1303
- Environment . VerifyProperties ( properties ) ;
1304
- Settings settings = BuildSettings ( ) ;
1305
-
1306
- // Ok, don't need schemas anymore, so free them
1307
- Schemas = null ;
1314
+ // Ok, don't need schemas anymore, so free them
1315
+ Schemas = null ;
1308
1316
1309
- return new SessionFactoryImpl ( this , new StaticDialectMappingWrapper ( mapping ) , settings , GetInitializedEventListeners ( ) ) ;
1317
+ return new SessionFactoryImpl (
1318
+ this ,
1319
+ mapping ,
1320
+ settings ,
1321
+ GetInitializedEventListeners ( ) ) ;
1322
+ }
1323
+ finally
1324
+ {
1325
+ mapping = dynamicDialectMapping ;
1326
+ }
1310
1327
}
1311
1328
1312
1329
/// <summary>
0 commit comments