diff --git a/.gitignore b/.gitignore index 3f06a689..13cc9c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ PrecompiledWeb /src/Spring/Spring.Core/Spring.Core.xml /src/Spring/Spring.Data.NHibernate3/Spring.Data.NHibernate3.xml /src/Spring/Spring.Data.NHibernate4/Spring.Data.NHibernate4.xml +/src/Spring/Spring.Data.NHibernate5/Spring.Data.NHibernate5.xml /src/Spring/Spring.Messaging.Ems/Spring.Messaging.Ems.xml /src/Spring/Spring.Messaging.Nms/Spring.Messaging.Nms.xml /src/Spring/Spring.Messaging/Spring.Messaging.xml diff --git a/Spring.Net.2010.sln b/Spring.Net.2010.sln index 3eb2c709..ed16a982 100644 --- a/Spring.Net.2010.sln +++ b/Spring.Net.2010.sln @@ -109,6 +109,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spring.Template.Velocity.Ca EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests", "test\Spring\Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests\Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests.csproj", "{DE276F7C-4564-49EC-AABC-B964EC3D1626}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate5.2010", "src\Spring\Spring.Data.NHibernate5\Spring.Data.NHibernate5.2010.csproj", "{26604974-B6B8-45BA-A72A-66574ADC498B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate5.Integration.Tests.2010", "test\Spring\Spring.Data.NHibernate5.Integration.Tests\Spring.Data.NHibernate5.Integration.Tests.2010.csproj", "{740CDA28-39BC-455A-86C3-5323D14F5B2E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate5.Tests.2010", "test\Spring\Spring.Data.NHibernate5.Tests\Spring.Data.NHibernate5.Tests.2010.csproj", "{BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -589,6 +595,42 @@ Global {DE276F7C-4564-49EC-AABC-B964EC3D1626}.Release|Any CPU.Build.0 = Release|Any CPU {DE276F7C-4564-49EC-AABC-B964EC3D1626}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {DE276F7C-4564-49EC-AABC-B964EC3D1626}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|.NET.ActiveCfg = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|.NET.Build.0 = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|.NET.ActiveCfg = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|.NET.Build.0 = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|Any CPU.Build.0 = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {26604974-B6B8-45BA-A72A-66574ADC498B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|.NET.ActiveCfg = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|.NET.Build.0 = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|.NET.ActiveCfg = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|.NET.Build.0 = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|Any CPU.Build.0 = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {740CDA28-39BC-455A-86C3-5323D14F5B2E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|.NET.ActiveCfg = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|.NET.Build.0 = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|.NET.ActiveCfg = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|.NET.Build.0 = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|Any CPU.Build.0 = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BEEBC49B-4519-4C77-AE93-11E68F4CA7E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Spring.build b/Spring.build index f59d2ac8..2407381a 100644 --- a/Spring.build +++ b/Spring.build @@ -377,6 +377,10 @@ Commandline Examples: + + + + @@ -411,6 +415,8 @@ Commandline Examples: + + @@ -892,30 +898,6 @@ Commandline Examples: - - - - - - - - - - - - - - - - - - - - - - - - @@ -1113,6 +1095,10 @@ Commandline Examples: + + + + @@ -1307,6 +1293,7 @@ Commandline Examples: + @@ -1317,6 +1304,7 @@ Commandline Examples: + @@ -1332,6 +1320,8 @@ Commandline Examples: + + @@ -1343,6 +1333,7 @@ Commandline Examples: + diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/BytecodeProvider.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/BytecodeProvider.cs index 1015476d..b38fa975 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/BytecodeProvider.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/BytecodeProvider.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using NHibernate.Bytecode; using NHibernate.Properties; diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/LazyInitializer.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/LazyInitializer.cs index 83fb2b53..b92f47a0 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/LazyInitializer.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/LazyInitializer.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using System.Reflection; using AopAlliance.Intercept; @@ -53,13 +49,22 @@ namespace Spring.Data.NHibernate.Bytecode /// /// public LazyInitializer(string entityName, Type persistentClass, object id, MethodInfo getIdentifierMethod, - MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, - ISessionImplementor session) + MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, + ISessionImplementor session) : base( - entityName, persistentClass, id, getIdentifierMethod, - setIdentifierMethod, componentIdType, session) { } - - #region Implementation of IInterceptor + entityName, + persistentClass, + id, + getIdentifierMethod, + setIdentifierMethod, + componentIdType, + session +#if NH_5 + , overridesEquals: false +#endif + ) + { + } /// /// Implement this method to perform extra treatments before and after @@ -106,27 +111,12 @@ namespace Spring.Data.NHibernate.Bytecode } } - #endregion - - #region Implementation of ITargetSource - - object ITargetSource.GetTarget() - { - return Target; - } + object ITargetSource.GetTarget() => Target; void ITargetSource.ReleaseTarget(object target) { } - Type ITargetSource.TargetType - { - get { return PersistentClass; } - } + Type ITargetSource.TargetType => PersistentClass; - bool ITargetSource.IsStatic - { - get { return false; } - } - - #endregion + bool ITargetSource.IsStatic => false; } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs index 21c44914..7b214ce5 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections.Generic; @@ -27,8 +21,6 @@ using NHibernate.Bytecode; using Spring.Objects.Factory; -#endregion - namespace Spring.Data.NHibernate.Bytecode { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactory.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactory.cs index 26369ef9..2d7c6e0b 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactory.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactory.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using Common.Logging; using NHibernate; @@ -46,8 +42,6 @@ namespace Spring.Data.NHibernate.Bytecode } } - #region IProxyFactory Members - /// /// Creates a new proxy. /// @@ -78,7 +72,5 @@ namespace Spring.Data.NHibernate.Bytecode throw new HibernateException("Creating a proxy instance failed", ex); } } - - #endregion } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactoryFactory.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactoryFactory.cs index 7f0c7980..69ecb3ec 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactoryFactory.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ProxyFactoryFactory.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,16 +14,10 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NHibernate.Bytecode; using NHibernate.Proxy; -#endregion - namespace Spring.Data.NHibernate.Bytecode { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs index e8f48e86..a30ee705 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections.Generic; @@ -27,8 +21,6 @@ using NHibernate.Properties; using Spring.Objects.Factory; -#endregion - namespace Spring.Data.NHibernate.Bytecode { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/DelegatingSessionFactory.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/DelegatingSessionFactory.cs index 99ee6ed6..122e7442 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/DelegatingSessionFactory.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/DelegatingSessionFactory.cs @@ -1,11 +1,19 @@ -using System.Data; +using System; using System.Collections.Generic; - +using System.Data.Common; +using System.Threading; +using System.Threading.Tasks; using NHibernate; using NHibernate.Engine; using NHibernate.Metadata; using NHibernate.Stat; +#if NH_5 +using IDbConnection = System.Data.Common.DbConnection; +#else +using IDbConnection = System.Data.IDbConnection; +#endif + namespace Spring.Data.NHibernate { #pragma warning disable 1591 @@ -14,150 +22,104 @@ namespace Spring.Data.NHibernate /// public abstract class DelegatingSessionFactory : ISessionFactory { - public ICollection DefinedFilterNames - { - get { return TargetSessionFactory.DefinedFilterNames; } - } + public abstract ISessionFactory TargetSessionFactory { get; } - public bool IsClosed - { - get { return TargetSessionFactory.IsClosed; } - } + public ICollection DefinedFilterNames => TargetSessionFactory.DefinedFilterNames; - public IStatistics Statistics - { - get { return TargetSessionFactory.Statistics; } - } + public bool IsClosed => TargetSessionFactory.IsClosed; - public abstract ISessionFactory TargetSessionFactory - { - get; - } + public IStatistics Statistics => TargetSessionFactory.Statistics; - public void Close() - { - TargetSessionFactory.Close(); - } + public void Close() => TargetSessionFactory.Close(); - public void Dispose() - { - TargetSessionFactory.Dispose(); - } + public void Dispose() => TargetSessionFactory.Dispose(); - public void Evict(System.Type persistentClass, object id) - { - TargetSessionFactory.Evict(persistentClass, id); - } + public void Evict(Type persistentClass, object id) => TargetSessionFactory.Evict(persistentClass, id); - public void Evict(System.Type persistentClass) - { - TargetSessionFactory.Evict(persistentClass); - } + public void Evict(Type persistentClass) => TargetSessionFactory.Evict(persistentClass); - public void EvictCollection(string roleName, object id) - { - TargetSessionFactory.EvictCollection(roleName, id); - } + public void EvictCollection(string roleName, object id) => TargetSessionFactory.EvictCollection(roleName, id); - public void EvictCollection(string roleName) - { - TargetSessionFactory.EvictCollection(roleName); - } + public void EvictCollection(string roleName) => TargetSessionFactory.EvictCollection(roleName); - public void EvictEntity(string entityName) - { - TargetSessionFactory.EvictEntity(entityName); - } + public void EvictEntity(string entityName) => TargetSessionFactory.EvictEntity(entityName); - public void EvictEntity(string entityName, object id) - { - TargetSessionFactory.EvictEntity(entityName, id); - } + public void EvictEntity(string entityName, object id) => TargetSessionFactory.EvictEntity(entityName, id); - public void EvictQueries(string cacheRegion) - { - TargetSessionFactory.EvictQueries(cacheRegion); - } + public void EvictQueries(string cacheRegion) => TargetSessionFactory.EvictQueries(cacheRegion); - public void EvictQueries() - { - TargetSessionFactory.EvictQueries(); - } + public void EvictQueries() => TargetSessionFactory.EvictQueries(); - public IDictionary GetAllClassMetadata() - { - return TargetSessionFactory.GetAllClassMetadata(); - } + public IDictionary GetAllClassMetadata() => TargetSessionFactory.GetAllClassMetadata(); - public IDictionary GetAllCollectionMetadata() - { - return TargetSessionFactory.GetAllCollectionMetadata(); - } - - public IClassMetadata GetClassMetadata(System.Type persistentType) - { - return TargetSessionFactory.GetClassMetadata(persistentType); - } - - public IClassMetadata GetClassMetadata(string entityName) - { - return TargetSessionFactory.GetClassMetadata(entityName); - } - - public ICollectionMetadata GetCollectionMetadata(string roleName) - { - return TargetSessionFactory.GetCollectionMetadata(roleName); - } - - public ISession GetCurrentSession() - { - return TargetSessionFactory.GetCurrentSession(); - } - - public FilterDefinition GetFilterDefinition(string filterName) - { - return TargetSessionFactory.GetFilterDefinition(filterName); - } - - public ISession OpenSession(IInterceptor interceptor) - { - return TargetSessionFactory.OpenSession(interceptor); - } - - public ISession OpenSession() - { - return TargetSessionFactory.OpenSession(); - } - - public ISession OpenSession(IDbConnection conn, IInterceptor interceptor) - { - return TargetSessionFactory.OpenSession(conn, interceptor); - } - - public ISession OpenSession(IDbConnection conn) - { - return TargetSessionFactory.OpenSession(conn); - } - - public IStatelessSession OpenStatelessSession() - { - return TargetSessionFactory.OpenStatelessSession(); - } + public IDictionary GetAllCollectionMetadata() + => TargetSessionFactory.GetAllCollectionMetadata(); public IStatelessSession OpenStatelessSession(IDbConnection connection) - { - return TargetSessionFactory.OpenStatelessSession(connection); - } + => TargetSessionFactory.OpenStatelessSession(connection); + + public IClassMetadata GetClassMetadata(Type persistentType) + => TargetSessionFactory.GetClassMetadata(persistentType); + + public IClassMetadata GetClassMetadata(string entityName) + => TargetSessionFactory.GetClassMetadata(entityName); + + public ICollectionMetadata GetCollectionMetadata(string roleName) + => TargetSessionFactory.GetCollectionMetadata(roleName); + + public ISession GetCurrentSession() => TargetSessionFactory.GetCurrentSession(); + + public FilterDefinition GetFilterDefinition(string filterName) + => TargetSessionFactory.GetFilterDefinition(filterName); + +#if NH_5 + public Task CloseAsync(CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.CloseAsync(cancellationToken); + + public Task EvictAsync(Type persistentClass, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictAsync(persistentClass, cancellationToken); + + public Task EvictAsync(Type persistentClass, object id, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictAsync(persistentClass, id, cancellationToken); + + public Task EvictEntityAsync(string entityName, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictEntityAsync(entityName, cancellationToken); + + public Task EvictEntityAsync(string entityName, object id, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictEntityAsync(entityName, id, cancellationToken); + + public Task EvictCollectionAsync(string roleName, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictCollectionAsync(roleName, cancellationToken); + + public Task EvictCollectionAsync(string roleName, object id, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictCollectionAsync(roleName, id, cancellationToken); + + public Task EvictQueriesAsync(CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictQueriesAsync(cancellationToken); + + public Task EvictQueriesAsync(string cacheRegion, CancellationToken cancellationToken = new CancellationToken()) + => TargetSessionFactory.EvictQueriesAsync(cacheRegion, cancellationToken); + + public ISessionBuilder WithOptions() => TargetSessionFactory.WithOptions(); + + public IStatelessSessionBuilder WithStatelessOptions() => TargetSessionFactory.WithStatelessOptions(); +#endif + + public ISession OpenSession(IInterceptor interceptor) => TargetSessionFactory.OpenSession(interceptor); + + public ISession OpenSession() => TargetSessionFactory.OpenSession(); + + public ISession OpenSession(IDbConnection conn, IInterceptor interceptor) + => TargetSessionFactory.OpenSession(conn, interceptor); + + public ISession OpenSession(IDbConnection conn) => TargetSessionFactory.OpenSession(conn); + + public IStatelessSession OpenStatelessSession() => TargetSessionFactory.OpenStatelessSession(); IDictionary ISessionFactory.GetAllClassMetadata() - { - return TargetSessionFactory.GetAllClassMetadata(); - } - - IDictionary ISessionFactory.GetAllCollectionMetadata() - { - return TargetSessionFactory.GetAllCollectionMetadata(); - } + => TargetSessionFactory.GetAllClassMetadata(); + IDictionary ISessionFactory.GetAllCollectionMetadata() + => TargetSessionFactory.GetAllCollectionMetadata(); } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/FilterDefinitionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/FilterDefinitionFactoryObject.cs index 3d9e00ea..86ca2987 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/FilterDefinitionFactoryObject.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/FilterDefinitionFactoryObject.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; using System.Collections.Generic; @@ -28,8 +22,6 @@ using NHibernate.Type; using Spring.Objects.Factory; -#endregion - namespace Spring.Data.NHibernate { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/FindHibernateDelegate.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/FindHibernateDelegate.cs index c291ba2d..25798072 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/FindHibernateDelegate.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/FindHibernateDelegate.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,15 +14,9 @@ * limitations under the License. */ -#endregion - -#region Imports - using NHibernate; using System.Collections.Generic; -#endregion - namespace Spring.Data.NHibernate.Generic { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDaoSupport.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDaoSupport.cs index 741bf506..6343ae77 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDaoSupport.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDaoSupport.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,17 +14,11 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NHibernate; using Spring.Dao; using Spring.Dao.Support; -#endregion - namespace Spring.Data.NHibernate.Generic.Support { /// @@ -50,14 +42,9 @@ namespace Spring.Data.NHibernate.Generic.Support /// Mark Pollack (.NET) public abstract class HibernateDaoSupport : DaoSupport { - #region Fields - - private HibernateTemplate hibernateTemplate; - - #endregion + private HibernateTemplate hibernateTemplate; - #region Constructor (s) - /// + /// /// Initializes a new instance of the class. /// public HibernateDaoSupport() @@ -65,11 +52,7 @@ namespace Spring.Data.NHibernate.Generic.Support } - #endregion - - #region Properties - - /// + /// /// Gets or sets the hibernate template. /// /// Set the HibernateTemplate for this DAO explicitly, @@ -130,11 +113,7 @@ namespace Spring.Data.NHibernate.Generic.Support } } - #endregion - - #region Methods - - /// + /// /// Create a HibernateTemplate for the given ISessionFactory. /// /// @@ -227,8 +206,5 @@ namespace Spring.Data.NHibernate.Generic.Support { SessionFactoryUtils.ReleaseSession(session, SessionFactory); } - #endregion - - } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDelegate.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDelegate.cs index 70e0c897..d069d44d 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDelegate.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateDelegate.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,14 +14,8 @@ * limitations under the License. */ -#endregion - -#region Imports - using NHibernate; -#endregion - namespace Spring.Data.NHibernate.Generic { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateTemplate.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateTemplate.cs index c4ee3617..f6f39b3c 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateTemplate.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/HibernateTemplate.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright � 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections.Generic; using NHibernate; @@ -30,8 +24,6 @@ using Spring.Data.Common; using Spring.Data.Support; using Spring.Objects.Factory; -#endregion - namespace Spring.Data.NHibernate.Generic { /// @@ -70,14 +62,8 @@ namespace Spring.Data.NHibernate.Generic /// Mark Pollack (.NET) public class HibernateTemplate : HibernateAccessor, IHibernateOperations { - #region Fields - NHibernate.HibernateTemplate classicHibernateTemplate; - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -357,17 +343,6 @@ namespace Spring.Data.NHibernate.Generic set { classicHibernateTemplate.ProxyFactory = value; } } - #endregion - - #region Properties - - - - - #endregion - - #region Methods - /// /// Remove all objects from the Session cache, and cancel all pending saves, /// updates and deletes. @@ -586,7 +561,7 @@ namespace Spring.Data.NHibernate.Generic classicHibernateTemplate.SaveOrUpdate(entity); } -#if !NH_4_0 +#if !NH_4_0 && !NH_5 /// /// Save or update the contents of given persistent object, /// according to its id (matching the configured "unsaved-value"?). @@ -624,10 +599,6 @@ namespace Spring.Data.NHibernate.Generic return classicHibernateTemplate.Merge(entity); } - #endregion - - #region IHibernateOperations Gets - /// /// Return the persistent instance of the given entity type /// with the given identifier, or null if not found. @@ -657,10 +628,6 @@ namespace Spring.Data.NHibernate.Generic return Execute(new GetByTypeHibernateCallback(id, lockMode), true); } - #endregion - - #region IHibernateOperations Loads - /// /// Return the persistent instance of the given entity class /// with the given identifier, throwing an exception if not found. @@ -703,10 +670,6 @@ namespace Spring.Data.NHibernate.Generic return ExecuteFind(new LoadAllByTypeHibernateCallback(this), true); } - #endregion - - #region IHibernateOperations Finds - /// /// Execute a query for persistent instances. /// @@ -1059,10 +1022,6 @@ namespace Spring.Data.NHibernate.Generic return ExecuteFind(new FindByValueObjectHibernateCallback(this, queryString, valueObject), true); } - #endregion - - #region Execute methods - /// /// Execute the action specified by the given action object within a Session. /// @@ -1335,13 +1294,8 @@ namespace Spring.Data.NHibernate.Generic { return ExecuteFind(action, ExposeNativeSession); } - - #endregion - } - #region Internal Supporting Callback Classes - internal class ExecuteHibernateCallbackUsingDelegate : IHibernateCallback { private HibernateDelegate del; @@ -1722,5 +1676,4 @@ namespace Spring.Data.NHibernate.Generic return del(session); } } - #endregion } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IFindHibernateCallback.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IFindHibernateCallback.cs index 239cb813..7c5e4664 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IFindHibernateCallback.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IFindHibernateCallback.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System.Collections.Generic; using NHibernate; diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateCallback.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateCallback.cs index 1f11cd3b..ac5a0b57 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateCallback.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateCallback.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,14 +14,8 @@ * limitations under the License. */ -#endregion - -#region Imports - using NHibernate; -#endregion - namespace Spring.Data.NHibernate.Generic { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateOperations.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateOperations.cs index b1f5fc4c..a0998b80 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateOperations.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Generic/IHibernateOperations.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using System.Collections.Generic; using NHibernate; diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAccessor.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAccessor.cs index d2c2c3f1..b8ff5ebf 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAccessor.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAccessor.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; using System.Reflection; @@ -35,8 +29,6 @@ using Spring.Objects.Factory; using IInterceptor=NHibernate.IInterceptor; using ICriteria=NHibernate.ICriteria; -#endregion - namespace Spring.Data.NHibernate { /// @@ -52,17 +44,11 @@ namespace Spring.Data.NHibernate { private Type criteriaType; - - #region Constants - /// + /// /// The instance for this class. /// private readonly ILog log = LogManager.GetLogger(typeof (HibernateAccessor)); - - #endregion - - #region Constructor (s) /// /// Initializes a new instance of the class. @@ -72,12 +58,7 @@ namespace Spring.Data.NHibernate } - #endregion - - - #region Properties - - /// + /// /// Gets or sets if a new Session should be created when no transactional Session /// can be found for the current thread. /// @@ -328,12 +309,8 @@ namespace Spring.Data.NHibernate } } - - #endregion - #region Methods - - /// + /// /// Apply the flush mode that's been specified for this accessor /// to the given Session. /// @@ -626,10 +603,8 @@ namespace Spring.Data.NHibernate log.Warn("CriteriaImpl not available. FetchSize can not be set on ICriteria objects", e); } } - - #endregion - /// + /// /// Ensure SessionFactory is not null /// /// If SessionFactory property is null. @@ -641,8 +616,7 @@ namespace Spring.Data.NHibernate } } - #region Helper Classes - /// + /// /// Helper class to determine if the FlushMode enumeration /// was changed from its default value /// @@ -690,11 +664,6 @@ namespace Spring.Data.NHibernate } } - - - #endregion - - } internal class CloseSuppressingMethodInterceptor : IMethodInterceptor diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAdoException.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAdoException.cs index 577d04e7..a7e3cc69 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAdoException.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateAdoException.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,36 +14,28 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Runtime.Serialization; using NHibernate; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { - /// + /// /// Hibernate-specific subclass of UncategorizedDataAccessException, /// for ADO.NET exceptions that Hibernate rethrew and could not be /// mapped into the DAO exception heirarchy. - /// - /// Mark Pollack (.NET) - [Serializable] - public class HibernateAdoException : UncategorizedDataAccessException - { - - #region Constructor (s) - - + /// + /// Mark Pollack (.NET) + [Serializable] + public class HibernateAdoException : UncategorizedDataAccessException + { /// /// Initializes a new instance of the class. /// - public HibernateAdoException() : base() {} + public HibernateAdoException() : base() + { + } /// /// Creates a new instance of the @@ -54,7 +44,9 @@ namespace Spring.Data.NHibernate /// /// A message about the exception. /// - public HibernateAdoException( string message ) : base( message ) {} + public HibernateAdoException(string message) : base(message) + { + } /// /// Creates a new instance of the @@ -66,8 +58,9 @@ namespace Spring.Data.NHibernate /// /// The root exception from the underlying data access API - ADO.NET /// - public HibernateAdoException( string message, ADOException rootCause ) : base( message, rootCause ) {} - + public HibernateAdoException(string message, ADOException rootCause) : base(message, rootCause) + { + } /// /// Creates a new instance of the HibernateSystemException class with the specified message @@ -83,23 +76,9 @@ namespace Spring.Data.NHibernate { } - /// - /// Creates a new instance of the - /// class. - /// - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected HibernateAdoException( SerializationInfo info, StreamingContext context ) : base( info, context ) {} - - - #endregion - - - } -} + /// + protected HibernateAdoException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateDelegate.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateDelegate.cs index 777e264f..b5eaa2c0 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateDelegate.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateDelegate.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,14 +14,8 @@ * limitations under the License. */ -#endregion - -#region Imports - using NHibernate; -#endregion - namespace Spring.Data.NHibernate { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateObjectRetrievalFailureException.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateObjectRetrievalFailureException.cs index 0e767f5a..81574670 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateObjectRetrievalFailureException.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateObjectRetrievalFailureException.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,40 +14,31 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Runtime.Serialization; using NHibernate; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { - /// - /// Hibernate-specific subclass of ObjectRetrievalFailureException. - /// - /// - /// Converts Hibernate's UnresolvableObjectException, ObjectNotFoundException, - /// ObjectDeletedException, and WrongClassException. - /// - /// Mark Pollack (.NET) - /// $Id: HibernateObjectRetrievalFailureException.cs,v 1.1 2008/04/07 20:12:53 lahma Exp $ - [Serializable] - public class HibernateObjectRetrievalFailureException : ObjectRetrievalFailureException - { - - #region Constructor (s) - + /// + /// Hibernate-specific subclass of ObjectRetrievalFailureException. + /// + /// + /// Converts Hibernate's UnresolvableObjectException, ObjectNotFoundException, + /// ObjectDeletedException, and WrongClassException. + /// + /// Mark Pollack (.NET) + /// $Id: HibernateObjectRetrievalFailureException.cs,v 1.1 2008/04/07 20:12:53 lahma Exp $ + [Serializable] + public class HibernateObjectRetrievalFailureException : ObjectRetrievalFailureException + { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public HibernateObjectRetrievalFailureException() - { - } + public HibernateObjectRetrievalFailureException() + { + } /// /// Initializes a new instance of the class. @@ -60,12 +49,12 @@ namespace Spring.Data.NHibernate { } - /// /// Initializes a new instance of the class. /// /// The ex. - public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) : base(ex.PersistentClass, ex.Identifier, ex.Message, ex) + public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) : base(ex.PersistentClass, + ex.Identifier, ex.Message, ex) { } @@ -73,8 +62,9 @@ namespace Spring.Data.NHibernate /// Initializes a new instance of the class. /// /// The ex. - public HibernateObjectRetrievalFailureException(ObjectNotFoundException ex) : base(ex.PersistentClass, ex.Identifier, ex.Message, ex) - + public HibernateObjectRetrievalFailureException(ObjectNotFoundException ex) : base(ex.PersistentClass, + ex.Identifier, ex.Message, ex) + { } @@ -82,9 +72,9 @@ namespace Spring.Data.NHibernate /// Initializes a new instance of the class. /// /// The ex. - public HibernateObjectRetrievalFailureException(ObjectDeletedException ex) : base(ex.PersistentClass, ex.Identifier, ex.Message, ex) + public HibernateObjectRetrievalFailureException(ObjectDeletedException ex) : base(ex.PersistentClass, + ex.Identifier, ex.Message, ex) { - } //TODO investigate WrongClassException.Type as equivalent to ex.PersistentClass @@ -92,8 +82,9 @@ namespace Spring.Data.NHibernate /// Initializes a new instance of the class. /// /// The ex. - public HibernateObjectRetrievalFailureException(WrongClassException ex) : base(ex.EntityName, ex.Identifier, ex.Message, ex) - { + public HibernateObjectRetrievalFailureException(WrongClassException ex) : base(ex.EntityName, ex.Identifier, + ex.Message, ex) + { } /// @@ -111,24 +102,10 @@ namespace Spring.Data.NHibernate { } - - /// - /// Creates a new instance of the - /// class. - /// - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// - /// The - /// that contains contextual information about the source or destination. - /// + /// protected HibernateObjectRetrievalFailureException( - SerializationInfo info, StreamingContext context ) : base( info, context ) {} - - - #endregion - - } -} + SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateOptimisticLockingFailureException.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateOptimisticLockingFailureException.cs index 9e467660..180d40e1 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateOptimisticLockingFailureException.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateOptimisticLockingFailureException.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,17 +14,11 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Runtime.Serialization; using NHibernate; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { /// @@ -41,12 +33,6 @@ namespace Spring.Data.NHibernate [Serializable] public class HibernateOptimisticLockingFailureException : ObjectOptimisticLockingFailureException { - #region Fields - - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -61,13 +47,16 @@ namespace Spring.Data.NHibernate /// /// A message about the exception. /// - public HibernateOptimisticLockingFailureException(string message) : base(message) { } + public HibernateOptimisticLockingFailureException(string message) : base(message) + { + } /// /// Initializes a new instance of the class. /// /// The ex. - public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) : base(ex.EntityName, ex.Identifier, ex.Message, ex) + public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) : base(ex.EntityName, + ex.Identifier, ex.Message, ex) { } @@ -76,8 +65,8 @@ namespace Spring.Data.NHibernate /// /// The StaleStateException. public HibernateOptimisticLockingFailureException(StaleStateException ex) : base(ex.Message, ex) - { - } + { + } /// /// Creates a new instance of the HibernateOptimisticLockingFailureException class with the specified message @@ -94,32 +83,10 @@ namespace Spring.Data.NHibernate { } - /// - /// Creates a new instance of the - /// class. - /// - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected HibernateOptimisticLockingFailureException(SerializationInfo info, StreamingContext context) : base(info, context) + /// + protected HibernateOptimisticLockingFailureException(SerializationInfo info, StreamingContext context) : base( + info, context) { } - - - - #endregion - - #region Properties - - #endregion - - #region Methods - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateQueryException.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateQueryException.cs index c80cab9f..250b0f01 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateQueryException.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateQueryException.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,17 +14,11 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Runtime.Serialization; using NHibernate; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { /// @@ -37,8 +29,6 @@ namespace Spring.Data.NHibernate [Serializable] public class HibernateQueryException : InvalidDataAccessResourceUsageException { - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -53,7 +43,9 @@ namespace Spring.Data.NHibernate /// /// A message about the exception. /// - public HibernateQueryException(string message) : base(message) { } + public HibernateQueryException(string message) : base(message) + { + } /// /// Initializes a new instance of the class. @@ -87,22 +79,9 @@ namespace Spring.Data.NHibernate get { return ((QueryException) this.InnerException).QueryString; } } - /// - /// Creates a new instance of the - /// class. - /// - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// - /// The - /// that contains contextual information about the source or destination. - /// + /// protected HibernateQueryException(SerializationInfo info, StreamingContext context) : base(info, context) { } - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateSystemException.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateSystemException.cs index 7612aed7..63f477d2 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateSystemException.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateSystemException.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,42 +14,34 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Runtime.Serialization; using NHibernate; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { - /// + /// /// Hibernate-specific subclass of UncategorizedDataAccessException, /// for Hibernate system errors that do not match any concrete /// Spring.Dao exceptions. - /// - /// Mark Pollack (.NET) - [Serializable] - public class HibernateSystemException : UncategorizedDataAccessException - { - - #region Constructor (s) - /// - /// Initializes a new instance of the class. + /// + /// Mark Pollack (.NET) + [Serializable] + public class HibernateSystemException : UncategorizedDataAccessException + { + /// + /// Initializes a new instance of the class. /// - public HibernateSystemException() - { - } + public HibernateSystemException() + { + } /// /// Initializes a new instance of the class. /// /// The message. - public HibernateSystemException(string message): base(message) + public HibernateSystemException(string message) : base(message) { } @@ -75,26 +65,11 @@ namespace Spring.Data.NHibernate /// The cause. public HibernateSystemException(HibernateException cause) : base(cause != null ? cause.Message : null, cause) { - } - /// - /// Creates a new instance of the - /// class. - /// - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected HibernateSystemException( SerializationInfo info, StreamingContext context ) : base( info, context ) {} - - - - #endregion - - } -} + /// + protected HibernateSystemException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTemplate.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTemplate.cs index 51c7bdc5..7b23dc7f 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTemplate.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTemplate.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; @@ -37,8 +31,6 @@ using NHibernate.Type; using Spring.Dao; using Spring.Objects.Factory; -#endregion - namespace Spring.Data.NHibernate { /// @@ -76,8 +68,6 @@ namespace Spring.Data.NHibernate /// Mark Pollack (.NET) public class HibernateTemplate : HibernateAccessor, IHibernateOperations { - #region Fields - /// /// The instance for this class. /// @@ -103,10 +93,6 @@ namespace Spring.Data.NHibernate private readonly object syncRoot = new object(); private ProxyFactory sessionProxyFactory; - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -141,10 +127,6 @@ namespace Spring.Data.NHibernate AfterPropertiesSet(); } - #endregion - - #region Properties - /// /// Gets or sets if a new Session should be created when no transactional Session /// can be found for the current thread. @@ -398,10 +380,6 @@ namespace Spring.Data.NHibernate set { sessionProxyFactory = value; } } - #endregion - - #region IHibernateOperations Members - /// /// Set the ADO.NET exception translator for this instance. /// Applied to System.Data.Common.DbException (or provider specific exception type @@ -646,7 +624,7 @@ namespace Spring.Data.NHibernate Execute(new SaveOrUpdateAllHibernateCallback(this, entities), true); } -#if !NH_4_0 +#if !NH_4_0 && !NH_5 /// /// Save or update the contents of given persistent object, /// according to its id (matching the configured "unsaved-value"?). @@ -1290,10 +1268,6 @@ namespace Spring.Data.NHibernate return (IList) Execute(new FindByValueObjectHibernateCallback(this, queryString, valueObject), true); } - #endregion - - #region Methods - /// /// Create a close-suppressing proxy for the given Hibernate Session. /// The proxy also prepares returned Query and Criteria objects. @@ -1366,12 +1340,8 @@ namespace Spring.Data.NHibernate } //TODO other combinations. } - - #endregion } - #region Internal Supporting Callback Classes - //TODO see if can create common base class for some callbacks. internal class ContainsHibernateCallback : IHibernateCallback @@ -2144,7 +2114,7 @@ namespace Spring.Data.NHibernate } } -#if !NH_4_0 +#if !NH_4_0 && !NH_5 internal class SaveOrUpdateCopyHibernateCallback : IHibernateCallback { private HibernateTemplate outer; @@ -2205,6 +2175,4 @@ namespace Spring.Data.NHibernate return session.Merge(entity); } } - - #endregion } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTransactionManager.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTransactionManager.cs index 59afd216..fcd1d7dc 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTransactionManager.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTransactionManager.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Data; using System.Reflection; @@ -37,8 +31,6 @@ using Spring.Transaction.Support; using HibernateTransactionException = NHibernate.TransactionException; -#endregion - namespace Spring.Data.NHibernate { /// @@ -65,8 +57,6 @@ namespace Spring.Data.NHibernate /// Mark Pollack (.NET) public class HibernateTransactionManager : AbstractPlatformTransactionManager, IResourceTransactionManager, IObjectFactoryAware, IInitializingObject { - #region Fields - private ISessionFactory sessionFactory; private IDbProvider dbProvider; @@ -84,10 +74,6 @@ namespace Spring.Data.NHibernate /// private IObjectFactory objectFactory; - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -105,10 +91,6 @@ namespace Spring.Data.NHibernate AfterPropertiesSet(); } - #endregion - - #region Properties - /// /// Gets or sets the db provider. /// @@ -264,13 +246,6 @@ namespace Spring.Data.NHibernate set { autodetectDbProvider = value; } } - #endregion - - #region Methods - - #endregion - - /// /// The object factory just needs to be known for resolving entity interceptor /// It does not need to be set for any other mode of operation. diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTxScopeTransactionManager.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTxScopeTransactionManager.cs index fa51c74e..73b09e8d 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTxScopeTransactionManager.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/HibernateTxScopeTransactionManager.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Data; using System.Reflection; @@ -36,8 +30,6 @@ using Spring.Objects.Factory; using Spring.Transaction; using Spring.Transaction.Support; -#endregion - namespace Spring.Data.NHibernate { /// @@ -64,8 +56,6 @@ namespace Spring.Data.NHibernate /// Mark Pollack (.NET) public class HibernateTxScopeTransactionManager : AbstractPlatformTransactionManager, IResourceTransactionManager, IObjectFactoryAware, IInitializingObject { - #region Fields - private ISessionFactory sessionFactory; private IDbProvider dbProvider; @@ -85,10 +75,6 @@ namespace Spring.Data.NHibernate private TxScopeTransactionManager txScopeTranactionManager; - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class. /// @@ -107,10 +93,6 @@ namespace Spring.Data.NHibernate AfterPropertiesSet(); } - #endregion - - #region Properties - /// /// Gets or sets the db provider. /// @@ -266,13 +248,6 @@ namespace Spring.Data.NHibernate set { autodetectDbProvider = value; } } - #endregion - - #region Methods - - #endregion - - /// /// The object factory just needs to be known for resolving entity interceptor /// It does not need to be set for any other mode of operation. diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/ICommonHibernateOperations.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/ICommonHibernateOperations.cs index 068210ef..ef31efb9 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/ICommonHibernateOperations.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/ICommonHibernateOperations.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,17 +14,10 @@ * limitations under the License. */ -#endregion - -#region Imports - -using System; using NHibernate; using NHibernate.Type; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { /// @@ -102,7 +93,7 @@ namespace Spring.Data.NHibernate /// Hibernate types of the parameters (or null) /// The number of entity instances deleted. /// In case of Hibernate errors - int Delete(String queryString, Object[] values, IType[] types); + int Delete(string queryString, object[] values, IType[] types); /// @@ -116,8 +107,6 @@ namespace Spring.Data.NHibernate /// In case of Hibernate errors void Flush(); - #region Convenience methods for loading individual objects - /// /// Load the persistent instance with the given identifier /// into the given object, throwing an exception if not found. @@ -162,11 +151,6 @@ namespace Spring.Data.NHibernate /// In case of Hibernate errors void Evict(object entity); - #endregion - - #region Convenience methods for storing individual objects - - /// /// Obtain the specified lock level upon the given object, implicitly /// checking whether the corresponding database entry still exists @@ -222,7 +206,7 @@ namespace Spring.Data.NHibernate /// In case of Hibernate errors void SaveOrUpdate(object entity); -#if !NH_4_0 +#if !NH_4_0 && !NH_5 /// /// Save or update the contents of given persistent object, /// according to its id (matching the configured "unsaved-value"?). @@ -253,7 +237,5 @@ namespace Spring.Data.NHibernate /// An updated persistent instance /// In case of Hibernate errors object Merge(object entity); - - #endregion } -} +} \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateCallback.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateCallback.cs index 09b3f598..6aba22be 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateCallback.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateCallback.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,14 +14,8 @@ * limitations under the License. */ -#endregion - -#region Imports - using NHibernate; -#endregion - namespace Spring.Data.NHibernate { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateOperations.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateOperations.cs index a813ca61..a154aad5 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateOperations.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/IHibernateOperations.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,18 +14,12 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; using NHibernate; using NHibernate.Type; using Spring.Dao; -#endregion - namespace Spring.Data.NHibernate { /// @@ -111,8 +103,7 @@ namespace Spring.Data.NHibernate /// In case of Hibernate errors IList ExecuteFind(IHibernateCallback action); - #region Finder Methods - /// + /// /// Execute a query for persistent instances. /// /// a query expressed in Hibernate's query language @@ -350,11 +341,7 @@ namespace Spring.Data.NHibernate /// In case of Hibernate errors IList FindByValueObject(string queryString, object valueObject); - #endregion - - #region Convenience methods for loading individual objects - - /// + /// /// Return the persistent instance of the given entity type /// with the given identifier, or null if not found. /// @@ -413,14 +400,7 @@ namespace Spring.Data.NHibernate IList LoadAll(Type entityType); - - - - #endregion - - #region Convenience methods for storing individual objects - - /// + /// /// Save or update all given persistent instances, /// according to its id (matching the configured "unsaved-value"?). /// @@ -428,9 +408,5 @@ namespace Spring.Data.NHibernate /// (to be associated with the Hibernate Session)he entities. /// In case of Hibernate errors void SaveOrUpdateAll(ICollection entities); - - - #endregion - } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs index 871c71ab..a46a4516 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,16 +14,13 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.Common; - +using System.Threading; +using System.Threading.Tasks; using Common.Logging; using NHibernate; using NHibernate.Bytecode; @@ -49,7 +44,11 @@ using Spring.Util; using Environment = NHibernate.Cfg.Environment; using Configuration = NHibernate.Cfg.Configuration; -#endregion +#if NH_5 +using IDbConnection = System.Data.Common.DbConnection; +#else +using IDbConnection = System.Data.IDbConnection; +#endif namespace Spring.Data.NHibernate { @@ -77,9 +76,7 @@ namespace Spring.Data.NHibernate public class LocalSessionFactoryObject : IFactoryObject, IInitializingObject, IPersistenceExceptionTranslator, IDisposable , IApplicationContextAware { - #region Fields - - private Configuration configuration; + private Configuration configuration; private ISessionFactory sessionFactory; @@ -93,9 +90,7 @@ namespace Spring.Data.NHibernate private IDbProvider dbProvider; - private bool exposeTransactionAwareSessionFactory = false; - - private IInterceptor entityInterceptor; + private IInterceptor entityInterceptor; private INamingStrategy namingStrategy; @@ -123,19 +118,12 @@ namespace Spring.Data.NHibernate private IBytecodeProvider bytecodeProvider; - #endregion - - #region Constants - /// /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof (LocalSessionFactoryObject)); - #endregion - - #region Constructor (s) /// /// Initializes a new instance of the class. /// @@ -144,17 +132,13 @@ namespace Spring.Data.NHibernate } - #endregion - - #region Properties - - /// + /// /// Setting the Application Context determines were resources are loaded from /// public IApplicationContext ApplicationContext { - set { this.applicationContext = value; } - protected get { return this.applicationContext; } + set { applicationContext = value; } + protected get { return applicationContext; } } /// @@ -170,8 +154,8 @@ namespace Spring.Data.NHibernate } return resourceLoader; } - set { resourceLoader = value; } - } + set => resourceLoader = value; + } /// /// Sets the assemblies to load that contain mapping files. @@ -179,7 +163,7 @@ namespace Spring.Data.NHibernate /// The mapping assemblies. public string[] MappingAssemblies { - set { mappingAssemblies = value; } + set => mappingAssemblies = value; } /// @@ -187,8 +171,8 @@ namespace Spring.Data.NHibernate /// public string[] ConfigFilenames { - set { configFilenames = value; } - } + set => configFilenames = value; + } /// /// Sets the locations of Spring IResources that contain mapping @@ -197,7 +181,7 @@ namespace Spring.Data.NHibernate /// The location of mapping resources. public string[] MappingResources { - set { mappingResources = value;} + set => mappingResources = value; } /// @@ -205,12 +189,9 @@ namespace Spring.Data.NHibernate /// Allows access to configuration metadata stored there (rarely needed). /// /// The hibernate configuration. - public Configuration Configuration - { - get { return configuration; } - } + public Configuration Configuration => configuration; - /// + /// /// Set NHibernate configuration properties, like "hibernate.dialect". /// /// The hibernate properties. @@ -233,11 +214,8 @@ namespace Spring.Data.NHibernate } return hibernateProperties; } - set - { - hibernateProperties = value; - } - } + set => hibernateProperties = value; + } /// /// Get or set the DataSource to be used by the SessionFactory. @@ -252,9 +230,9 @@ namespace Spring.Data.NHibernate /// public IDbProvider DbProvider { - set { dbProvider = value; } - get { return dbProvider; } - } + set => dbProvider = value; + get => dbProvider; + } /// /// Gets or sets a value indicating whether to expose a transaction aware session factory. @@ -262,14 +240,10 @@ namespace Spring.Data.NHibernate /// /// true if want to expose transaction aware session factory; otherwise, false. /// - public bool ExposeTransactionAwareSessionFactory - { - set { exposeTransactionAwareSessionFactory = value; } - get { return exposeTransactionAwareSessionFactory; } - } + public bool ExposeTransactionAwareSessionFactory { set; get; } = false; - /// + /// /// Set a NHibernate entity interceptor that allows to inspect and change /// property values before writing to and reading from the database. /// Will get applied to any new Session created by this factory. @@ -283,7 +257,7 @@ namespace Spring.Data.NHibernate /// public IInterceptor EntityInterceptor { - set { this.entityInterceptor = value; } + set => entityInterceptor = value; } /// @@ -292,7 +266,7 @@ namespace Spring.Data.NHibernate /// public INamingStrategy NamingStrategy { - set { this.namingStrategy = value; } + set => namingStrategy = value; } /// @@ -306,7 +280,7 @@ namespace Spring.Data.NHibernate /// public IObjectDefinition[] TypeDefinitions { - set { this.typeDefinitions = value; } + set => typeDefinitions = value; } @@ -323,8 +297,8 @@ namespace Spring.Data.NHibernate /// public FilterDefinition[] FilterDefinitions { - set { this.filterDefinitions = value; } - } + set => filterDefinitions = value; + } /// /// Specify the cache strategies for entities (persistent classes or named entities). @@ -342,7 +316,7 @@ namespace Spring.Data.NHibernate /// public Properties EntityCacheStrategies { - set { this.entityCacheStrategies = value; } + set => entityCacheStrategies = value; } /// @@ -361,7 +335,7 @@ namespace Spring.Data.NHibernate /// public Properties CollectionCacheStrategies { - set { this.collectionCacheStrategies = value; } + set => collectionCacheStrategies = value; } @@ -380,7 +354,7 @@ namespace Spring.Data.NHibernate /// public IDictionary EventListeners { - set { this.eventListeners = value; } + set => eventListeners = value; } /// @@ -393,8 +367,8 @@ namespace Spring.Data.NHibernate /// public bool SchemaUpdate { - set { schemaUpdate = value; } - } + set => schemaUpdate = value; + } /// /// Set the ADO.NET exception translator for this instance. @@ -408,8 +382,8 @@ namespace Spring.Data.NHibernate /// The ADO exception translator. public virtual IAdoExceptionTranslator AdoExceptionTranslator { - set { adoExceptionTranslator = value; } - get + set => adoExceptionTranslator = value; + get { if (adoExceptionTranslator == null) { @@ -426,17 +400,11 @@ namespace Spring.Data.NHibernate /// public virtual IBytecodeProvider BytecodeProvider { - get { return this.bytecodeProvider; } - set { this.bytecodeProvider = value; } - } + get => bytecodeProvider; + set => bytecodeProvider = value; + } - #endregion - - #region Methods - - #endregion - - /// + /// /// Return the singleon session factory. /// /// The singleon session factory. @@ -449,24 +417,15 @@ namespace Spring.Data.NHibernate /// Return the type or subclass. /// /// The type created by this factory - public Type ObjectType - { - get - { - return (sessionFactory != null) ? sessionFactory.GetType() : typeof(ISessionFactory); - } - } + public Type ObjectType => (sessionFactory != null) ? sessionFactory.GetType() : typeof(ISessionFactory); - /// + /// /// Returns true /// /// true - public bool IsSingleton - { - get { return true; } - } + public bool IsSingleton => true; - /// + /// /// Initialize the SessionFactory for the given or the /// default location. /// @@ -475,11 +434,11 @@ namespace Spring.Data.NHibernate // Create Configuration instance. Configuration config = NewConfiguration(); - if (this.dbProvider != null) + if (dbProvider != null) { config.SetProperty(Environment.ConnectionString, dbProvider.ConnectionString); config.SetProperty(Environment.ConnectionProvider, typeof(DbProviderWrapper).AssemblyQualifiedName); - configTimeDbProvider = this.dbProvider; + configTimeDbProvider = dbProvider; } if (ExposeTransactionAwareSessionFactory) @@ -490,19 +449,19 @@ namespace Spring.Data.NHibernate config.SetProperty(Environment.CurrentSessionContextClass, typeof(SpringSessionContext).AssemblyQualifiedName); } - if (this.entityInterceptor != null) + if (entityInterceptor != null) { // Set given entity interceptor at SessionFactory level. - config.SetInterceptor(this.entityInterceptor); + config.SetInterceptor(entityInterceptor); } - if (this.namingStrategy != null) + if (namingStrategy != null) { // Pass given naming strategy to Hibernate Configuration. - config.SetNamingStrategy(this.namingStrategy); + config.SetNamingStrategy(namingStrategy); } - if (this.typeDefinitions != null) + if (typeDefinitions != null) { // Register specified Hibernate type definitions. IDictionary typedProperties = new Dictionary(); @@ -513,9 +472,9 @@ namespace Spring.Data.NHibernate Dialect dialect = Dialect.GetDialect(typedProperties); Mappings mappings = config.CreateMappings(dialect); - for (int i = 0; i < this.typeDefinitions.Length; i++) + for (int i = 0; i < typeDefinitions.Length; i++) { - IObjectDefinition typeDef = this.typeDefinitions[i]; + IObjectDefinition typeDef = typeDefinitions[i]; Dictionary typedParamMap = new Dictionary(); foreach (DictionaryEntry entry in typeDef.PropertyValues) { @@ -525,28 +484,27 @@ namespace Spring.Data.NHibernate } } - if (this.filterDefinitions != null) + if (filterDefinitions != null) { // Register specified NHibernate FilterDefinitions. - for (int i = 0; i < this.filterDefinitions.Length; i++) + for (int i = 0; i < filterDefinitions.Length; i++) { - config.AddFilterDefinition(this.filterDefinitions[i]); + config.AddFilterDefinition(filterDefinitions[i]); } } - if (this.hibernateProperties != null) + if (hibernateProperties != null) { if (config.GetProperty(Environment.ConnectionProvider) != null && hibernateProperties.ContainsKey(Environment.ConnectionProvider)) { - #region Logging - if (log.IsInfoEnabled) + if (log.IsInfoEnabled) { log.Info("Overriding use of Spring's Hibernate Connection Provider with [" + hibernateProperties[Environment.ConnectionProvider] + "]"); } - #endregion - config.Properties.Remove(Environment.ConnectionProvider); + + config.Properties.Remove(Environment.ConnectionProvider); } Dictionary genericHibernateProperties = new Dictionary(); @@ -556,7 +514,7 @@ namespace Spring.Data.NHibernate } config.AddProperties(genericHibernateProperties); } - if (this.mappingAssemblies != null) + if (mappingAssemblies != null) { foreach (string assemblyName in mappingAssemblies) { @@ -564,12 +522,12 @@ namespace Spring.Data.NHibernate } } - if (this.mappingResources != null) + if (mappingResources != null) { - IResourceLoader loader = this.ResourceLoader; + IResourceLoader loader = ResourceLoader; if (loader == null) { - loader = this.applicationContext; + loader = applicationContext; } foreach (string resourceName in mappingResources) { @@ -590,12 +548,12 @@ namespace Spring.Data.NHibernate PostProcessMappings(config); config.BuildMappings(); - if (this.entityCacheStrategies != null) + if (entityCacheStrategies != null) { // Register cache strategies for mapped entities. - foreach (string className in this.entityCacheStrategies.Keys) + foreach (string className in entityCacheStrategies.Keys) { - string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.entityCacheStrategies.GetProperty(className)); + string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(entityCacheStrategies.GetProperty(className)); if (strategyAndRegion.Length > 1) { config.SetCacheConcurrencyStrategy(className, strategyAndRegion[0], strategyAndRegion[1]); @@ -607,12 +565,12 @@ namespace Spring.Data.NHibernate } } - if (this.collectionCacheStrategies != null) + if (collectionCacheStrategies != null) { // Register cache strategies for mapped collections. foreach (string collRole in collectionCacheStrategies.Keys) { - string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.collectionCacheStrategies.GetProperty(collRole)); + string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(collectionCacheStrategies.GetProperty(collRole)); if (strategyAndRegion.Length > 1) { throw new Exception("Collection cache concurrency strategy region definition not supported yet"); @@ -625,7 +583,7 @@ namespace Spring.Data.NHibernate } } - if (this.eventListeners != null) + if (eventListeners != null) { // Register specified NHibernate event listeners. foreach (DictionaryEntry entry in eventListeners) @@ -674,8 +632,8 @@ namespace Spring.Data.NHibernate // Build SessionFactory instance. log.Info("Building new Hibernate SessionFactory"); - this.configuration = config; - this.sessionFactory = NewSessionFactory(config); + configuration = config; + sessionFactory = NewSessionFactory(config); AfterSessionFactoryCreation(); @@ -690,13 +648,12 @@ namespace Spring.Data.NHibernate { if (sessionFactory != null) { - #region Instrumentation - if (log.IsInfoEnabled) + if (log.IsInfoEnabled) { log.Info("Closing Hibernate SessionFactory"); } - #endregion - sessionFactory.Close(); + + sessionFactory.Close(); } } @@ -748,7 +705,7 @@ namespace Spring.Data.NHibernate /// protected virtual void AfterSessionFactoryCreation() { - if (this.schemaUpdate) + if (schemaUpdate) { UpdateDatabaseSchema(); } @@ -934,31 +891,14 @@ namespace Spring.Data.NHibernate return sf; } - #region DbProviderWrapper Helper class - - internal class DbProviderWrapper : ConnectionProvider + internal class DbProviderWrapper : ConnectionProvider { - private IDbProvider _dbProvider; + public IDbProvider DbProvider { get; set; } - public DbProviderWrapper() +#if NH_5 + public override async Task GetConnectionAsync(CancellationToken cancellationToken) { - } - - public IDbProvider DbProvider - { - get { return _dbProvider; } - set { _dbProvider = value; } - } - - public override void CloseConnection(IDbConnection conn) - { - base.CloseConnection(conn); - conn.Dispose(); - } - - public override IDbConnection GetConnection() - { - IDbProvider provider = _dbProvider; + IDbProvider provider = DbProvider; if (provider == null && configTimeDbProvider != null) { // NH 2.1 has a need to access db provider before @@ -971,17 +911,40 @@ namespace Spring.Data.NHibernate { throw new Exception("There was no DB provider available, unable to create connection"); } - IDbConnection dbCon = provider.CreateConnection(); + var dbCon = (DbConnection) provider.CreateConnection(); + await dbCon.OpenAsync(cancellationToken).ConfigureAwait(false); + return dbCon; + } +#endif + + public override void CloseConnection(IDbConnection conn) + { + base.CloseConnection(conn); + conn.Dispose(); + } + + public override IDbConnection GetConnection() + { + IDbProvider provider = DbProvider; + if (provider == null && configTimeDbProvider != null) + { + // NH 2.1 has a need to access db provider before + // it has been set "the natural way" (it gets the DB's reserved words) + // allow it via configuration time db provider reference + provider = configTimeDbProvider; + } + + if (provider == null) + { + throw new Exception("There was no DB provider available, unable to create connection"); + } + var dbCon = (IDbConnection) provider.CreateConnection(); dbCon.Open(); return dbCon; } } - - #endregion // DbProviderWrapper Helper class - - #region IPersistenceExceptionTranslator Members - - /// + + /// /// Implementation of the PersistenceExceptionTranslator interface, /// as autodetected by Spring's PersistenceExceptionTranslationPostProcessor. /// Converts the exception if it is a HibernateException; @@ -1034,7 +997,5 @@ namespace Spring.Data.NHibernate { return SessionFactoryUtils.ConvertAdoAccessException(AdoExceptionTranslator, ex); } - - #endregion } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs index 200ff37b..7689a434 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Collections; using System.Collections.Generic; @@ -39,8 +33,6 @@ using Spring.Threading; using Spring.Transaction.Support; using Spring.Util; -#endregion - namespace Spring.Data.NHibernate { /// @@ -51,18 +43,12 @@ namespace Spring.Data.NHibernate /// Mark Pollack (.NET) public abstract class SessionFactoryUtils { - #region Fields - - /// + /// /// The instance for this class. /// private static readonly ILog log = LogManager.GetLogger(typeof(SessionFactoryUtils)); - #endregion - - #region Constants - - /// + /// /// The ordering value for synchronizaiton this session resources. /// Set to be lower than ADO.NET synchronization. /// @@ -71,10 +57,7 @@ namespace Spring.Data.NHibernate private static readonly string DeferredCloseHolderDataSlotName = "Spring.Data.NHibernate:deferredCloseHolder"; - #endregion - - #region Constructor (s) - /// + /// /// Initializes a new instance of the class. /// public SessionFactoryUtils() @@ -82,15 +65,7 @@ namespace Spring.Data.NHibernate } - #endregion - - #region Properties - - #endregion - - #region Methods - - /// + /// /// Get a new Hibernate Session from the given SessionFactory. /// Will return a new Session even if there already is a pre-bound /// Session for the given SessionFactory. @@ -401,9 +376,7 @@ namespace Spring.Data.NHibernate return (sessionHolder != null && sessionHolder.ContainsSession(session)); } - #endregion - - /// + /// /// Converts a Hibernate ADOException to a Spring DataAccessExcption, extracting the underlying error code from /// ADO.NET. Will extract the ADOException Message and SqlString properties and pass them to the translate method /// of the provided IAdoExceptionTranslator. @@ -699,6 +672,7 @@ namespace Spring.Data.NHibernate IList providerNames = ctx.GetObjectNamesForType(typeof(DbProvider), true, false); string hibCommandAQN = hibCommandType.AssemblyQualifiedName; + string hibCommandAQNWithoutVersion = hibCommandType.FullName + ", " + hibCommandType.Assembly.GetName().Name; foreach (string providerName in providerNames) { IObjectDefinition objectdef = ctx.ObjectFactory.GetObjectDefinition(providerName); @@ -708,7 +682,7 @@ namespace Spring.Data.NHibernate ConstructorArgumentValues dbmdCtorArgs = od.ConstructorArgumentValues; string commandType = dbmdCtorArgs.GetArgumentValue("commandType", typeof(string)).Value as string; - if (hibCommandAQN.Equals(commandType)) + if (hibCommandAQN.Equals(commandType) || hibCommandAQNWithoutVersion.Equals(commandType)) { IDbProvider prov = DbProviderFactory.GetDbProvider(providerName); return prov; diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs index c85bb43a..e28756b2 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System.Collections; using System.Collections.Generic; using System.Data; @@ -29,8 +23,6 @@ using NHibernate; using Spring.Transaction.Support; using Spring.Util; -#endregion - namespace Spring.Data.NHibernate { /// @@ -44,9 +36,7 @@ namespace Spring.Data.NHibernate /// Mark Pollack (.NET) public class SessionHolder : ResourceHolderSupport { - #region Fields - - private static readonly object DEFAULT_KEY = new object(); + private static readonly object DEFAULT_KEY = new object(); private readonly object sessionDictionaryLock = new object(); private readonly Dictionary sessionDictionary = new Dictionary(1); @@ -60,16 +50,8 @@ namespace Spring.Data.NHibernate //needed to see if we actually assigned the enum value... private bool assignedPreviousFlushMode = false; - #endregion - - #region Logging Definition - private static readonly ILog log = LogManager.GetLogger(typeof (SessionHolder)); - #endregion - - #region Constructor (s) - /// /// May be used by derived classes to create an empty SessionHolder. /// @@ -106,12 +88,8 @@ namespace Spring.Data.NHibernate { // noop here - but may be overridden to lazily create a session } - - #endregion - #region Properties - - /// + /// /// Gets the session using the default key /// /// The hibernate session. @@ -255,11 +233,7 @@ namespace Spring.Data.NHibernate } } - #endregion - - #region Methods - - /// + /// /// Gets the session given key identifier /// /// The key. @@ -373,8 +347,5 @@ namespace Spring.Data.NHibernate assignedPreviousFlushMode = false; Connection = null; } - - #endregion - } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionContext.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionContext.cs index 0b45d4c0..62acf4dd 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionContext.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionContext.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using NHibernate; using NHibernate.Context; @@ -52,8 +48,6 @@ namespace Spring.Data.NHibernate this.sessionFactory = sessionFactory; } - #region ICurrentSessionContext Members - /// /// Retrieve the Spring-managed Session for the current thread. /// @@ -70,7 +64,5 @@ namespace Spring.Data.NHibernate throw new HibernateException(ex.Message); } } - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionSynchronization.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionSynchronization.cs index 3025e498..707fdb87 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionSynchronization.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SpringSessionSynchronization.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using Common.Logging; using NHibernate; using NHibernate.Engine; @@ -27,23 +21,19 @@ using Spring.Core; using Spring.Data.Support; using Spring.Transaction.Support; -#endregion - namespace Spring.Data.NHibernate { - /// - /// NHibnerations actions taken during the transaction lifecycle. - /// - /// Mark Pollack (.NET) - public class SpringSessionSynchronization : TransactionSynchronizationAdapter, IOrdered - { - #region Fields - + /// + /// NHibnerations actions taken during the transaction lifecycle. + /// + /// Mark Pollack (.NET) + public class SpringSessionSynchronization : TransactionSynchronizationAdapter, IOrdered + { /// /// The instance for this class. /// private readonly ILog log = LogManager.GetLogger(typeof(SpringSessionSynchronization)); - + private readonly SessionHolder sessionHolder; private readonly ISessionFactory sessionFactory; @@ -53,24 +43,18 @@ namespace Spring.Data.NHibernate private readonly bool newSession; private bool holderActive = true; - #endregion - #region Constructor (s) - /// - /// Initializes a new instance of the class. + /// + /// Initializes a new instance of the class. /// - public SpringSessionSynchronization(SessionHolder sessionHolder, ISessionFactory sessionFactory, - IAdoExceptionTranslator adoExceptionTranslator, bool newSession) - { + public SpringSessionSynchronization(SessionHolder sessionHolder, ISessionFactory sessionFactory, + IAdoExceptionTranslator adoExceptionTranslator, bool newSession) + { this.sessionHolder = sessionHolder; this.sessionFactory = sessionFactory; this.adoExceptionTranslator = adoExceptionTranslator; this.newSession = newSession; - } - - #endregion - - #region Properties + } /// /// Return the order value of this object, where a higher value means greater in @@ -90,104 +74,96 @@ namespace Spring.Data.NHibernate /// The order value. public int Order { - get - { - return SessionFactoryUtils.SESSION_SYNCHRONIZATION_ORDER; - } + get { return SessionFactoryUtils.SESSION_SYNCHRONIZATION_ORDER; } } - #endregion - - #region Methods - - /// - /// Suspend this synchronization. - /// - /// - ///

- /// Unbind Hibernate resources (SessionHolder) from - /// - /// if managing any. - ///

- ///
- public override void Suspend() - { - if (this.holderActive) + /// + /// Suspend this synchronization. + /// + /// + ///

+ /// Unbind Hibernate resources (SessionHolder) from + /// + /// if managing any. + ///

+ ///
+ public override void Suspend() + { + if (this.holderActive) { TransactionSynchronizationManager.UnbindResource(this.sessionFactory); } - } + } - /// - /// Resume this synchronization. - /// - /// - ///

- /// Rebind Hibernate resources from - /// - /// if managing any. - ///

- ///
- public override void Resume() - { - if (this.holderActive) + /// + /// Resume this synchronization. + /// + /// + ///

+ /// Rebind Hibernate resources from + /// + /// if managing any. + ///

+ ///
+ public override void Resume() + { + if (this.holderActive) { TransactionSynchronizationManager.BindResource(this.sessionFactory, this.sessionHolder); } - } + } - /// - /// Invoked before transaction commit (before - /// ) - /// - /// - /// If the transaction is defined as a read-only transaction. - /// - /// - ///

- /// Can flush transactional sessions to the database. - ///

- ///

- /// Note that exceptions will get propagated to the commit caller and - /// cause a rollback of the transaction. - ///

- ///
- public override void BeforeCommit(bool readOnly) - { - if (!readOnly) - { + /// + /// Invoked before transaction commit (before + /// ) + /// + /// + /// If the transaction is defined as a read-only transaction. + /// + /// + ///

+ /// Can flush transactional sessions to the database. + ///

+ ///

+ /// Note that exceptions will get propagated to the commit caller and + /// cause a rollback of the transaction. + ///

+ ///
+ public override void BeforeCommit(bool readOnly) + { + if (!readOnly) + { // read-write transaction -> flush the Hibernate Session - log.Debug("Flushing Hibernate Session on transaction synchronization"); + log.Debug("Flushing Hibernate Session on transaction synchronization"); ISession session = this.sessionHolder.Session; //Further check: only flush when not FlushMode.NEVER if (session.FlushMode != FlushMode.Never) { - try + try { session.Flush(); //TODO can throw System.ObjectDisposedException... } - catch (ADOException ex) + catch (ADOException ex) { - if (this.adoExceptionTranslator != null) + if (this.adoExceptionTranslator != null) { //TODO investigate how ADOException wraps inner exception. throw this.adoExceptionTranslator.Translate( "Hibernate transaction synchronization: " + ex.Message, null, ex.InnerException); } - else + else { throw new HibernateAdoException("ADO.NET Exception", ex); } } - catch (HibernateException ex) + catch (HibernateException ex) { throw SessionFactoryUtils.ConvertHibernateAccessException(ex); } } - - } - } + } + } /// /// Invoked before transaction commit (before @@ -209,67 +185,66 @@ namespace Spring.Data.NHibernate /// (note: do not throw TransactionException subclasses here!) /// /// - public override void BeforeCompletion() - { - if (this.newSession) + public override void BeforeCompletion() + { + if (this.newSession) { // Default behavior: unbind and close the thread-bound Hibernate Session. TransactionSynchronizationManager.UnbindResource(this.sessionFactory); this.holderActive = false; } - else if (this.sessionHolder.AssignedPreviousFlushMode == true) + else if (this.sessionHolder.AssignedPreviousFlushMode == true) { // In case of pre-bound Session, restore previous flush mode. this.sessionHolder.Session.FlushMode = (this.sessionHolder.PreviousFlushMode); } - } + } - /// - /// Invoked after transaction commit/rollback. - /// - /// - /// Status according to - /// - /// - /// Can e.g. perform resource cleanup, in this case after transaction completion. - ///

- /// Note that exceptions will get propagated to the commit or rollback - /// caller, although they will not influence the outcome of the transaction. - ///

- ///
- public override void AfterCompletion(TransactionSynchronizationStatus status) - { - if (!newSession) - { + /// + /// Invoked after transaction commit/rollback. + /// + /// + /// Status according to + /// + /// + /// Can e.g. perform resource cleanup, in this case after transaction completion. + ///

+ /// Note that exceptions will get propagated to the commit or rollback + /// caller, although they will not influence the outcome of the transaction. + ///

+ ///
+ public override void AfterCompletion(TransactionSynchronizationStatus status) + { + if (!newSession) + { ISession session = sessionHolder.Session; - + // Provide correct transaction status for releasing the Session's cache locks, // if possible. Else, closing will release all cache locks assuming a rollback. ISessionImplementor sessionImplementor = session as ISessionImplementor; - if (sessionImplementor != null) - { - sessionImplementor.AfterTransactionCompletion(status == TransactionSynchronizationStatus.Committed, sessionHolder.Transaction); - } + if (sessionImplementor != null) + { + sessionImplementor.AfterTransactionCompletion(status == TransactionSynchronizationStatus.Committed, + sessionHolder.Transaction); + } if (newSession) { SessionFactoryUtils.CloseSessionOrRegisterDeferredClose(session, sessionFactory); - } - } + } + } + if (!newSession && status != TransactionSynchronizationStatus.Committed) { // Clear all pending inserts/updates/deletes in the Session. // Necessary for pre-bound Sessions, to avoid inconsistent state. sessionHolder.Session.Clear(); } - - if (this.sessionHolder.DoesNotHoldNonDefaultSession) { - sessionHolder.SynchronizedWithTransaction = false; - } + if (this.sessionHolder.DoesNotHoldNonDefaultSession) + { + sessionHolder.SynchronizedWithTransaction = false; + } } - - #endregion - } -} +} \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/ConfigSectionSessionScopeSettings.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/ConfigSectionSessionScopeSettings.cs index 453f5b42..14fd2857 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/ConfigSectionSessionScopeSettings.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/ConfigSectionSessionScopeSettings.cs @@ -1,5 +1,3 @@ -#region Licence - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NHibernate; using Spring.Context; @@ -27,8 +21,6 @@ using Spring.Context.Support; using Spring.Objects.Factory.Config; using Spring.Util; -#endregion - namespace Spring.Data.NHibernate.Support { /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/HibernateDaoSupport.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/HibernateDaoSupport.cs index dda28710..cd7f22cb 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/HibernateDaoSupport.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/HibernateDaoSupport.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,17 +14,11 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NHibernate; using Spring.Dao; using Spring.Dao.Support; -#endregion - namespace Spring.Data.NHibernate.Support { /// @@ -49,14 +41,9 @@ namespace Spring.Data.NHibernate.Support /// Mark Pollack (.NET) public abstract class HibernateDaoSupport : DaoSupport { - #region Fields - - private HibernateTemplate hibernateTemplate; - - #endregion + private HibernateTemplate hibernateTemplate; - #region Constructor (s) - /// + /// /// Initializes a new instance of the class. /// public HibernateDaoSupport() @@ -64,11 +51,7 @@ namespace Spring.Data.NHibernate.Support } - #endregion - - #region Properties - - /// + /// /// Gets or sets the hibernate template. /// /// Set the HibernateTemplate for this DAO explicitly, @@ -129,13 +112,7 @@ namespace Spring.Data.NHibernate.Support } } - - - #endregion - - #region Methods - - /// + /// /// Create a HibernateTemplate for the given ISessionFactory. /// /// @@ -227,10 +204,5 @@ namespace Spring.Data.NHibernate.Support protected void ReleaseSession(ISession session) { SessionFactoryUtils.ReleaseSession(session, SessionFactory); } - #endregion - - - - } } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScope.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScope.cs index efcef9ff..865755b8 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScope.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScope.cs @@ -1,5 +1,3 @@ -#region Licence - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using System.Reflection; @@ -29,8 +23,6 @@ using Spring.Threading; using Spring.Transaction.Support; using Spring.Util; -#endregion - namespace Spring.Data.NHibernate.Support { /// @@ -64,8 +56,6 @@ namespace Spring.Data.NHibernate.Support /// Harald Radi (.NET) public class SessionScope : IDisposable { - #region Fields - /// /// The logging instance. /// @@ -77,10 +67,6 @@ namespace Spring.Data.NHibernate.Support private readonly string PARTICIPATE_KEY; private readonly string ISOPEN_KEY; - #endregion - - #region Constructor (s) - /// /// Initializes a new instance of the class in single session mode, /// associating a session with the thread. The session is opened lazily on demand. @@ -209,10 +195,6 @@ namespace Spring.Data.NHibernate.Support } } - #endregion - - #region Properties - /// /// Set whether to use a single session for each request. Default is "true". /// If set to false, each data access operation or transaction will use @@ -313,10 +295,6 @@ namespace Spring.Data.NHibernate.Support } } - #endregion - - #region IDisposable Members - /// /// Call Close(), /// @@ -325,10 +303,6 @@ namespace Spring.Data.NHibernate.Support Close(); } - #endregion - - #region Methods - /// /// Opens a new session or participates in an existing session and /// registers with spring's . @@ -434,10 +408,6 @@ namespace Spring.Data.NHibernate.Support return session; } - #endregion - - #region LazySessionHolder utility class - /// /// This sessionHolder creates a default session only if it is needed. /// @@ -488,7 +458,5 @@ namespace Spring.Data.NHibernate.Support if (log.IsDebugEnabled) log.Debug("Closed LazySessionHolder"); } } - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScopeSettings.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScopeSettings.cs index 018bc149..13ba439d 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScopeSettings.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScopeSettings.cs @@ -1,5 +1,3 @@ -#region Licence - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,16 +14,10 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NHibernate; using Spring.Util; -#endregion - namespace Spring.Data.NHibernate.Support { /// @@ -113,8 +105,6 @@ namespace Spring.Data.NHibernate.Support this.defaultFlushMode = defaultFlushMode; } - #region Properties - /// /// Gets the configured instance to be used. /// @@ -187,8 +177,6 @@ namespace Spring.Data.NHibernate.Support set { defaultFlushMode = value; } } - #endregion - /// /// Override this method to resolve an instance according to your chosen strategy. /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/TemplateFlushMode.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/TemplateFlushMode.cs index 6518a2d8..c4a8c8fe 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/TemplateFlushMode.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/TemplateFlushMode.cs @@ -1,5 +1,3 @@ -#region License - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,9 +14,6 @@ * limitations under the License. */ -#endregion - - namespace Spring.Data.NHibernate { /// diff --git a/src/Spring/Spring.Data.NHibernate3/Spring.Data.NHibernate3.build b/src/Spring/Spring.Data.NHibernate3/Spring.Data.NHibernate3.build deleted file mode 100644 index fd92d87f..00000000 --- a/src/Spring/Spring.Data.NHibernate3/Spring.Data.NHibernate3.build +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Spring/Spring.Data.NHibernate4/AssemblyInfo.cs b/src/Spring/Spring.Data.NHibernate4/AssemblyInfo.cs index 1ec3c0c5..aa8444aa 100644 --- a/src/Spring/Spring.Data.NHibernate4/AssemblyInfo.cs +++ b/src/Spring/Spring.Data.NHibernate4/AssemblyInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyTitle("Spring.Net NHibernate 3.3 support")] -[assembly: AssemblyDescription("Interfaces and classes that provide NHibernate 3.3 support in Spring.Net")] \ No newline at end of file +[assembly: AssemblyTitle("Spring.Net NHibernate 4.0 support")] +[assembly: AssemblyDescription("Interfaces and classes that provide NHibernate 4.0 support in Spring.Net")] \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate4/Spring.Data.NHibernate4.build b/src/Spring/Spring.Data.NHibernate4/Spring.Data.NHibernate4.build deleted file mode 100644 index bed55718..00000000 --- a/src/Spring/Spring.Data.NHibernate4/Spring.Data.NHibernate4.build +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Spring/Spring.Data.NHibernate5/AssemblyInfo.cs b/src/Spring/Spring.Data.NHibernate5/AssemblyInfo.cs new file mode 100644 index 00000000..403626b8 --- /dev/null +++ b/src/Spring/Spring.Data.NHibernate5/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Reflection; + +[assembly: AssemblyTitle("Spring.Net NHibernate 5.0 support")] +[assembly: AssemblyDescription("Interfaces and classes that provide NHibernate 5.0 support in Spring.Net")] \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Bytecode/dontdelete.txt b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Bytecode/dontdelete.txt new file mode 100644 index 00000000..9b957720 --- /dev/null +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Bytecode/dontdelete.txt @@ -0,0 +1 @@ +sources are linked here from Spring.Data.NHibernate21 \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Generic/dontdelete.txt b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Generic/dontdelete.txt new file mode 100644 index 00000000..b4472e3f --- /dev/null +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Generic/dontdelete.txt @@ -0,0 +1 @@ +sources are linked here from Spring.Data.NHibernate \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/dontdelete.txt b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/dontdelete.txt new file mode 100644 index 00000000..b4472e3f --- /dev/null +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/dontdelete.txt @@ -0,0 +1 @@ +sources are linked here from Spring.Data.NHibernate \ No newline at end of file diff --git a/src/Spring/Spring.Data.NHibernate5/Spring.Data.NHibernate5.2010.csproj b/src/Spring/Spring.Data.NHibernate5/Spring.Data.NHibernate5.2010.csproj new file mode 100644 index 00000000..94a82a27 --- /dev/null +++ b/src/Spring/Spring.Data.NHibernate5/Spring.Data.NHibernate5.2010.csproj @@ -0,0 +1,149 @@ + + + netstandard2.0;net461 + Interfaces and classes that provide NHibernate 5 support in Spring.Net + $(DefineConstants);NH_5 + 0618 + + + + + + + + + + + + + + + + + GenCommonAssemblyInfo.cs + + + Data\NHibernate\Bytecode\BytecodeProvider.cs + + + Data\NHibernate\Bytecode\LazyInitializer.cs + + + Data\NHibernate\Bytecode\ObjectsFactory.cs + + + Data\NHibernate\Bytecode\ProxyFactory.cs + + + Data\NHibernate\Bytecode\ProxyFactoryFactory.cs + + + Data\NHibernate\Bytecode\ReflectionOptimizer.cs + + + Data\NHibernate\DelegatingLocalSessionFactoryObject.cs + + + Data\NHibernate\DelegatingSessionFactory.cs + + + Data\NHibernate\FilterDefinitionFactoryObject.cs + + + Data\NHibernate\Generic\FindHibernateDelegate.cs + + + Data\NHibernate\Generic\HibernateDaoSupport.cs + + + Data\NHibernate\Generic\HibernateDelegate.cs + + + Data\NHibernate\Generic\HibernateTemplate.cs + + + Data\NHibernate\Generic\IFindHibernateCallback.cs + + + Data\NHibernate\Generic\IHibernateCallback.cs + + + Data\NHibernate\Generic\IHibernateOperations.cs + + + Data\NHibernate\HibernateAccessor.cs + + + Data\NHibernate\HibernateAdoException.cs + + + Data\NHibernate\HibernateDelegate.cs + + + Data\NHibernate\HibernateObjectRetrievalFailureException.cs + + + Data\NHibernate\HibernateOptimisticLockingFailureException.cs + + + Data\NHibernate\HibernateQueryException.cs + + + Data\NHibernate\HibernateSystemException.cs + + + Data\NHibernate\HibernateTemplate.cs + + + Data\NHibernate\HibernateTransactionManager.cs + + + Data\NHibernate\HibernateTxScopeTransactionManager.cs + + + Data\NHibernate\ICommonHibernateOperations.cs + + + Data\NHibernate\IHibernateCallback.cs + + + Data\NHibernate\IHibernateOperations.cs + + + Data\NHibernate\LocalSessionFactoryObject.cs + + + Data\NHibernate\SessionFactoryUtils.cs + + + Data\NHibernate\SessionHolder.cs + + + Data\NHibernate\SimpleDelegatingSessionFactory.cs + + + Data\NHibernate\SpringSessionContext.cs + + + Data\NHibernate\SpringSessionSynchronization.cs + + + Data\NHibernate\Support\ConfigSectionSessionScopeSettings.cs + + + Data\NHibernate\Support\HibernateDaoSupport.cs + + + Data\NHibernate\Support\OpenSessionInViewModule.cs + + + Data\NHibernate\Support\SessionScope.cs + + + Data\NHibernate\Support\SessionScopeSettings.cs + + + Data\NHibernate\TemplateFlushMode.cs + + + \ No newline at end of file diff --git a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs index cf94a94f..263bdb09 100644 --- a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs +++ b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs @@ -1,5 +1,3 @@ -#region Licence - /* * Copyright © 2002-2011 the original author or authors. * @@ -16,8 +14,6 @@ * limitations under the License. */ -#endregion - using System; using System.Collections.Generic; @@ -42,8 +38,6 @@ namespace Spring.Data.Common /// Mark Pollack (.NET) public class DbProviderFactory { - #region Constants - /// /// The shared log instance for this class (and derived classes). /// @@ -57,15 +51,8 @@ namespace Spring.Data.Common private static readonly string DBPROVIDER_CONTEXTNAME = "DBPROVIDERFACTORY_CONTEXT"; - #endregion - - #region Fields - private volatile static XmlApplicationContext ctx; - #endregion - - #region Constructor (s) /// /// Initializes a new instance of the class. /// @@ -73,9 +60,6 @@ namespace Spring.Data.Common { } - #endregion - - /// /// Gets the DbProvider given an identifying name. /// @@ -131,13 +115,12 @@ namespace Spring.Data.Common if (loader.GetResource(DBPROVIDER_ADDITIONAL_RESOURCE_NAME).Exists) { - #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsDebugEnabled) { log.Debug("Loading additional DbProviders from " + DBPROVIDER_ADDITIONAL_RESOURCE_NAME); } - #endregion - ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME, + + ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME, DBPROVIDER_ADDITIONAL_RESOURCE_NAME}); } else @@ -148,7 +131,7 @@ namespace Spring.Data.Common IList dbProviderNames = ctx.GetObjectNames(); if (log.IsInfoEnabled) { - log.Info(String.Format("{0} DbProviders Available. [{1}]", dbProviderNames.Count, StringUtils.CollectionToCommaDelimitedString(dbProviderNames))); + log.Info(string.Format("{0} DbProviders Available. [{1}]", dbProviderNames.Count, StringUtils.CollectionToCommaDelimitedString(dbProviderNames))); } } catch (Exception e) diff --git a/src/Spring/Spring.Data/Data/Common/IDbProvider.cs b/src/Spring/Spring.Data/Data/Common/IDbProvider.cs index 48153d44..f77c9e3e 100644 --- a/src/Spring/Spring.Data/Data/Common/IDbProvider.cs +++ b/src/Spring/Spring.Data/Data/Common/IDbProvider.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/Spring/Spring.Data/Data/Common/dbproviders.xml b/src/Spring/Spring.Data/Data/Common/dbproviders.xml index 0a575460..b274d853 100644 --- a/src/Spring/Spring.Data/Data/Common/dbproviders.xml +++ b/src/Spring/Spring.Data/Data/Common/dbproviders.xml @@ -3,7 +3,10 @@ - + diff --git a/src/Spring/Spring.Data/Data/Common/dbproviders_netcore.xml b/src/Spring/Spring.Data/Data/Common/dbproviders_netcore.xml new file mode 100644 index 00000000..467020e3 --- /dev/null +++ b/src/Spring/Spring.Data/Data/Common/dbproviders_netcore.xml @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 102,156,170,207,208 + + + 229 + + + 544,2627,8114,8115 + + + 1205 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 900,903,904,917,936,942,17006 + + + 17003 + + + 1 + + + 17002,17447 + + + 1,1400,1722,2291,2292 + + + 54 + + + 8177 + + + 60 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1054,1064,1146 + + + 1 + + + 630,839,840,893,1062,1169,1215,1216,1217,1451,1452,1557 + + + 1205 + + + 1213 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 03000,42000,42601,42602,42622,42804,42P01 + + + 53000,53100,53200,53300 + + + 23000,23502,23503,23505,23514 + + + 55P03 + + + 40001 + + + 40P01 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + 15 + + + 5,6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -104 + + + -901 + + + -530 + + + -913 + + + + + + + + diff --git a/src/Spring/Spring.Data/Spring.Data.2010.csproj b/src/Spring/Spring.Data/Spring.Data.2010.csproj index 4935bc4e..2cb0cad3 100644 --- a/src/Spring/Spring.Data/Spring.Data.2010.csproj +++ b/src/Spring/Spring.Data/Spring.Data.2010.csproj @@ -21,15 +21,20 @@ spring-database-1.3.xsd - + + Spring.Data.Common.dbproviders.xml + + + Spring.Data.Common.dbproviders.xml + - - - - + + + + \ No newline at end of file diff --git a/src/Spring/Spring.Data/Spring.Data.build b/src/Spring/Spring.Data/Spring.Data.build deleted file mode 100644 index edac8bc6..00000000 --- a/src/Spring/Spring.Data/Spring.Data.build +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml index fce7fffd..f3317929 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml @@ -3,7 +3,7 @@ xmlns:db="http://www.springframework.net/database"> diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml b/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml index c875f727..4219bde1 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml @@ -11,7 +11,7 @@ --> diff --git a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/AbstractInjectableUserTypeFixture.cs b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/AbstractInjectableUserTypeFixture.cs index ea55e891..867725f4 100644 --- a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/AbstractInjectableUserTypeFixture.cs +++ b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/AbstractInjectableUserTypeFixture.cs @@ -16,7 +16,7 @@ namespace Spring.Data.NHibernate.Bytecode static AbstractInjectableUserTypeFixture() { - XmlConfigurator.Configure(); + //XmlConfigurator.Configure(); } /// diff --git a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/InjectableStringUserType.cs b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/InjectableStringUserType.cs index eb2eeac5..89185954 100644 --- a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/InjectableStringUserType.cs +++ b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/Bytecode/InjectableStringUserType.cs @@ -1,6 +1,7 @@ using System.Data; - +using System.Data.Common; using NHibernate; +using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -15,9 +16,31 @@ namespace Spring.Data.NHibernate.Bytecode this.delimiter = delimiter; } +#if NH_5 + public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner) + { + string resultString = (string) NHibernateUtil.String.NullSafeGet(rs, names[0], session); + if (resultString != null) + return delimiter.Delimit(resultString); + return null; + } + + public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) + { + if (value == null) + { + NHibernateUtil.String.NullSafeSet(cmd, null, index, session); + return; + } + + value = delimiter.Delimit((string) value); + + NHibernateUtil.String.NullSafeSet(cmd, value, index, session); + } +#else public object NullSafeGet(IDataReader rs, string[] names, object owner) { - string resultString = (string)NHibernateUtil.String.NullSafeGet(rs, names[0]); + string resultString = (string) NHibernateUtil.String.NullSafeGet(rs, names[0]); if (resultString != null) return delimiter.Delimit(resultString); return null; @@ -31,15 +54,16 @@ namespace Spring.Data.NHibernate.Bytecode return; } - value = delimiter.Delimit((string)value); + value = delimiter.Delimit((string) value); NHibernateUtil.String.NullSafeSet(cmd, value, index); } +#endif public object DeepCopy(object value) { if (value == null) return null; - return string.Copy((string)value); + return string.Copy((string) value); } public object Replace(object original, object target, object owner) @@ -57,23 +81,11 @@ namespace Spring.Data.NHibernate.Bytecode return DeepCopy(value); } - public SqlType[] SqlTypes - { - get - { - return new SqlType[] { new SqlType(DbType.String) }; - } - } + public SqlType[] SqlTypes => new[] {new SqlType(DbType.String)}; - public System.Type ReturnedType - { - get { return typeof(string); } - } + public System.Type ReturnedType => typeof(string); - public bool IsMutable - { - get { return false; } - } + public bool IsMutable => false; public new bool Equals(object x, object y) { @@ -86,4 +98,4 @@ namespace Spring.Data.NHibernate.Bytecode return x.GetHashCode(); } } -} +} \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/NHDAOTests.cs b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/NHDAOTests.cs index fc58e298..e15ca47c 100644 --- a/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/NHDAOTests.cs +++ b/test/Spring/Spring.Data.NHibernate.Integration.Tests/Data/NHibernate/NHDAOTests.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,12 +62,10 @@ namespace Spring.Data.NHibernate [Test] public void DbProviderTranslation() { - ISessionFactory sf = ctx["SessionFactory"] as ISessionFactory; IDbProvider dbProvider = SessionFactoryUtils.GetDbProvider(sf); - Assert.IsTrue(dbProvider.DbMetadata.ProductName.Contains("Microsoft SQL Server, provider")); - Assert.IsTrue(dbProvider.DbMetadata.ProductName.Contains("in framework .NET")); + Assert.That(dbProvider.DbMetadata.ProductName, Does.Contain("Microsoft SQL Server")); } [Test] diff --git a/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/HibernateTransactionManagerTests.cs b/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/HibernateTransactionManagerTests.cs index 2a517e9c..952d6ff0 100644 --- a/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/HibernateTransactionManagerTests.cs +++ b/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/HibernateTransactionManagerTests.cs @@ -32,6 +32,12 @@ using Spring.Support; using Spring.Transaction; using Spring.Transaction.Support; +#if NH_5 +using IDbConnection = System.Data.Common.DbConnection; +#else +using IDbConnection = System.Data.IDbConnection; +#endif + namespace Spring.Data.NHibernate { /// diff --git a/test/Spring/Spring.Data.NHibernate3.Integration.Tests/Spring.Data.NHibernate3.Integration.Tests.build b/test/Spring/Spring.Data.NHibernate3.Integration.Tests/Spring.Data.NHibernate3.Integration.Tests.build deleted file mode 100644 index 371742f6..00000000 --- a/test/Spring/Spring.Data.NHibernate3.Integration.Tests/Spring.Data.NHibernate3.Integration.Tests.build +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.NHibernate3.Tests/Spring.Data.NHibernate3.Tests.build b/test/Spring/Spring.Data.NHibernate3.Tests/Spring.Data.NHibernate3.Tests.build deleted file mode 100644 index b8561ce6..00000000 --- a/test/Spring/Spring.Data.NHibernate3.Tests/Spring.Data.NHibernate3.Tests.build +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.NHibernate4.Integration.Tests/Spring.Data.NHibernate4.Integration.Tests.build b/test/Spring/Spring.Data.NHibernate4.Integration.Tests/Spring.Data.NHibernate4.Integration.Tests.build deleted file mode 100644 index 61e5a901..00000000 --- a/test/Spring/Spring.Data.NHibernate4.Integration.Tests/Spring.Data.NHibernate4.Integration.Tests.build +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests.build b/test/Spring/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests.build deleted file mode 100644 index d8d748da..00000000 --- a/test/Spring/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests/Spring.Data.NHibernate4.NestedTxSuspension.Integration.Tests.build +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.NHibernate4.Tests/Spring.Data.NHibernate4.Tests.build b/test/Spring/Spring.Data.NHibernate4.Tests/Spring.Data.NHibernate4.Tests.build deleted file mode 100644 index 4e64ccb7..00000000 --- a/test/Spring/Spring.Data.NHibernate4.Tests/Spring.Data.NHibernate4.Tests.build +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/App.config b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/App.config new file mode 100644 index 00000000..868ceb0c --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/App.config @@ -0,0 +1,39 @@ + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/AssemblyInfo.cs b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/AssemblyInfo.cs new file mode 100644 index 00000000..05c9f94c --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Reflection; + +[assembly: AssemblyTitle("Spring.Data.NHibernate5 Integration Tests")] +[assembly: AssemblyDescription("Integration tests for Spring.Data.NHibernate5 assembly")] diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Bytecode/Foo.Spechbm.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Bytecode/Foo.Spechbm.xml new file mode 100644 index 00000000..38faa3e6 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Bytecode/Foo.Spechbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Credit.hbm.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Credit.hbm.xml new file mode 100644 index 00000000..4aa9c9be --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Credit.hbm.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Dao.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Dao.xml new file mode 100644 index 00000000..482061d5 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Dao.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + Spring.Data.NHibernate5.Integration.Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Debit.hbm.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Debit.hbm.xml new file mode 100644 index 00000000..ecdd0cc8 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/Debit.hbm.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/MultipleDbTests.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/MultipleDbTests.xml new file mode 100644 index 00000000..1a24c20f --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/MultipleDbTests.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + Spring.Data.NHibernate5.Integration.Tests + + + + + + + + + + + + + + + + + + + + + + Spring.Data.NHibernate5.Integration.Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + transactionInterceptor + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/NHDAOTests.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/NHDAOTests.xml new file mode 100644 index 00000000..42efc820 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/NHDAOTests.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + Spring.Data.NHibernate5.Integration.Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + transactionInterceptor + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/TestObject.hbm.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/TestObject.hbm.xml new file mode 100644 index 00000000..b7ce0425 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/TestObject.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/dbProviderTemplateTests.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/dbProviderTemplateTests.xml new file mode 100644 index 00000000..0e8dfa48 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/dbProviderTemplateTests.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + assembly://Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate/TestObject.hbm.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/templateTests.xml b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/templateTests.xml new file mode 100644 index 00000000..abca45e4 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Data/NHibernate/templateTests.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + assembly://Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate/TestObject.hbm.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.2010.csproj b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.2010.csproj new file mode 100644 index 00000000..e34fd446 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.2010.csproj @@ -0,0 +1,128 @@ + + + netcoreapp2.1;net461 + $(DefineConstants);NH_5 + + + + + + + + + + + + + + + + + + + + Data\NHibernate\AccountController.cs + + + Data\NHibernate\AccountCreditDao.cs + + + Data\NHibernate\AccountDebitDao.cs + + + Data\NHibernate\AccountManager.cs + + + Data\NHibernate\AuditDao.cs + + + Data\Bytecode\AbstractInjectableUserTypeFixture.cs + + + Data\Bytecode\Foo.cs + + + Data\Bytecode\IDelimiter.cs + + + Data\Bytecode\InjectableStringUserType.cs + + + Data\Bytecode\InjectableUserTypeFixture.cs + + + Data\Bytecode\Product.cs + + + Data\NHibernate\Credit.cs + + + Data\NHibernate\DbProviderTemplateTests.cs + + + Data\NHibernate\Debit.cs + + + Data\NHibernate\HibernateTxScopeTransactionManagerTests.cs + + + Data\NHibernate\IAccountController.cs + + + Data\NHibernate\IAccountCreditDao.cs + + + Data\NHibernate\IAccountDebitDao.cs + + + Data\NHibernate\IAccountManager.cs + + + Data\NHibernate\IAuditDao.cs + + + Data\NHibernate\ITestObjectDao.cs + + + Data\NHibernate\MultipleDbTests.cs + + + Data\NHibernate\NativeNHTestObjectDao.cs + + + Data\NHibernate\NativeNHTests.cs + + + Data\NHibernate\NHDAOTests.cs + + + Data\NHibernate\NHTestObjectDao.cs + + + Data\NHibernate\SimpleTestDao.cs + + + Data\NHibernate\TemplateTests.cs + + + Data\NHibernate\TestObject.cs + + + Data\NHibernate\creditdebit.sql + + + PreserveNewest + + + Data\NHibernate\HibernateTxScopeTransactionManagerTests.xml + + + + + Data\NHibernate\Controllers.xml + + + Data\NHibernate\Services.xml + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/App.config b/test/Spring/Spring.Data.NHibernate5.Tests/App.config new file mode 100644 index 00000000..00e338fd --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/App.config @@ -0,0 +1,30 @@ + + + + +
+ + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/AssemblyInfo.cs b/test/Spring/Spring.Data.NHibernate5.Tests/AssemblyInfo.cs new file mode 100644 index 00000000..84a4520c --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Reflection; + +[assembly: AssemblyTitle("Spring.Data.NHibernate5 Tests")] +[assembly: AssemblyDescription("Unit tests for Spring.Data.NHibernate5 assembly")] diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfiguration.xml b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfiguration.xml new file mode 100644 index 00000000..e5821310 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfiguration.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + assembly://Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate/TestObject.hbm.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + loggingAroundAdvice + + + + + + + + + + TestObjectDao + + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfigurationTxPointcut.xml b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfigurationTxPointcut.xml new file mode 100644 index 00000000..055fac12 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/Config/AopConfigurationTxPointcut.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + assembly://Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate/TestObject.hbm.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12341234asdf* + + + + + + + + + loggingAdvisor + + + + + + + + + + TestObjectDao + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/TestObject.hbm.xml b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/TestObject.hbm.xml new file mode 100644 index 00000000..16395eea --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/Data/NHibernate/TestObject.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.2010.csproj b/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.2010.csproj new file mode 100644 index 00000000..b8dfc2b9 --- /dev/null +++ b/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.2010.csproj @@ -0,0 +1,67 @@ + + + netcoreapp2.1;net461 + $(DefineConstants);NH_5 + + + + + + + + + + + + + + + + + + Data\NHibernate\Config\AopConfiguration.cs + + + Data\NHibernate\DelegatingLocalSessionFactoryObjectTests.cs + + + Data\NHibernate\HibernateTransactionManagerTests.cs + + + Data\NHibernate\ISimpleService.cs + + + Data\NHibernate\ITestObjectDao.cs + + + Data\NHibernate\LocalSessionFactoryObjectTests.cs + + + Data\NHibernate\NHTestObjectDao.cs + + + Data\NHibernate\SessionFactoryUtilsTests.cs + + + Data\NHibernate\SimpleService.cs + + + Data\NHibernate\Support\ConfigSectionSessionScopeSettingsTests.cs + + + Data\NHibernate\Support\SessionScopeSettingsTests.cs + + + Data\NHibernate\Support\SessionScopeTests.cs + + + Data\NHibernate\TestObject.cs + + + PreserveNewest + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs b/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs index a34672b2..055cc068 100644 --- a/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs +++ b/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,10 +80,16 @@ namespace Spring.Data.Common [Test] public void ThreadSafety() { - AsyncTestTask t1 = new AsyncTestDbProviderFactory(1000, "SqlServer-2.0").Start(); - AsyncTestTask t2 = new AsyncTestDbProviderFactory(1000, "SqlServer-2.0").Start(); - AsyncTestTask t3 = new AsyncTestDbProviderFactory(1000, "SqlServer-2.0").Start(); - AsyncTestTask t4 = new AsyncTestDbProviderFactory(1000, "SqlServer-2.0").Start(); +#if NETCOREAPP + const string providerName = "SqlServer"; +#else + const string providerName = "SqlServer-2.0"; +#endif + + AsyncTestTask t1 = new AsyncTestDbProviderFactory(1000, providerName).Start(); + AsyncTestTask t2 = new AsyncTestDbProviderFactory(1000, providerName).Start(); + AsyncTestTask t3 = new AsyncTestDbProviderFactory(1000, providerName).Start(); + AsyncTestTask t4 = new AsyncTestDbProviderFactory(1000, providerName).Start(); t1.AssertNoException(); t2.AssertNoException(); @@ -166,7 +172,6 @@ namespace Spring.Data.Common Assert.IsNotNull(provider.CreateParameter()); Assert.AreEqual("?", provider.CreateParameterName("Foo")); } -#endif [Test] public void DefaultInstanceWithSqlServer40() @@ -182,6 +187,17 @@ namespace Spring.Data.Common Assert.AreEqual("@Foo", provider.CreateParameterName("Foo")); } + [Test] + public void TestSqlServer20Names() + { + //Initialize internal application context. factory + DbProviderFactory.GetDbProvider("SqlServer-2.0"); + IApplicationContext ctx = DbProviderFactory.ApplicationContext; + IList dbProviderNames = ctx.GetObjectNamesForType(typeof (IDbProvider)); + Assert.IsTrue(dbProviderNames.Count > 0); + } +#endif + [Test] public void DefaultInstanceWithOracleClient10_20() { @@ -273,16 +289,6 @@ namespace Spring.Data.Common */ - [Test] - public void TestSqlServer20Names() - { - //Initialize internal application context. factory - DbProviderFactory.GetDbProvider("SqlServer-2.0"); - IApplicationContext ctx = DbProviderFactory.ApplicationContext; - IList dbProviderNames = ctx.GetObjectNamesForType(typeof (IDbProvider)); - Assert.IsTrue(dbProviderNames.Count > 0); - } - private void AssertIsSqlServer2005(IDbProvider provider) { Assert.AreEqual("Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0", diff --git a/test/Spring/Spring.Data.Tests/Support/ErrorCodeExceptionTranslatorTests.cs b/test/Spring/Spring.Data.Tests/Support/ErrorCodeExceptionTranslatorTests.cs index 055cd4ea..b743bd0e 100644 --- a/test/Spring/Spring.Data.Tests/Support/ErrorCodeExceptionTranslatorTests.cs +++ b/test/Spring/Spring.Data.Tests/Support/ErrorCodeExceptionTranslatorTests.cs @@ -1,7 +1,5 @@ -#region Licence - /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +14,6 @@ * limitations under the License. */ -#endregion - -#region Imports - using System; using NUnit.Framework; using Spring.Dao; @@ -27,8 +21,6 @@ using Spring.Data; using Spring.Data.Common; using Spring.Data.Support; -#endregion - namespace Spring.Support { /// @@ -38,16 +30,11 @@ namespace Spring.Support [TestFixture] public class ErrorCodeExceptionTranslatorTests { - #region Fields - private static ErrorCodes ERROR_CODES = new ErrorCodes(); + private static ErrorCodes ERROR_CODES = new ErrorCodes(); private IDbProvider dbProvider = new TestDbProvider(); - #endregion - - #region Constructor (s) - - /// + /// /// Initializes a new instance of the class. /// public ErrorCodeExceptionTranslatorTests() @@ -55,15 +42,7 @@ namespace Spring.Support } - #endregion - - #region Properties - - #endregion - - - - [SetUp] + [SetUp] public void SetUp() { ERROR_CODES.BadSqlGrammarCodes = (new String[] { "1", "2" }); diff --git a/test/Spring/Spring.Data.Tests/Support/TestDbProvider.cs b/test/Spring/Spring.Data.Tests/Support/TestDbProvider.cs index 5a6b1412..f4f21aa5 100644 --- a/test/Spring/Spring.Data.Tests/Support/TestDbProvider.cs +++ b/test/Spring/Spring.Data.Tests/Support/TestDbProvider.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,9 +41,8 @@ namespace Spring.Support public TestDbProvider() { - IDbProvider provider = DbProviderFactory.GetDbProvider("SqlServer-1.1"); + IDbProvider provider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); dbMetadata = provider.DbMetadata; - } /// diff --git a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/TestApplicationContext.xml b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/TestApplicationContext.xml index a5702f11..405b503c 100644 --- a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/TestApplicationContext.xml +++ b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/TestApplicationContext.xml @@ -3,7 +3,7 @@ xmlns:db="http://www.springframework.net/database">