From: <fab...@us...> - 2009-06-25 04:59:35
|
Revision: 4531 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4531&view=rev Author: fabiomaulo Date: 2009-06-25 04:59:34 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Removed empty namespace Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Loader/Hql/ Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-25 04:19:42 UTC (rev 4530) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-25 04:59:34 UTC (rev 4531) @@ -1331,9 +1331,6 @@ <ItemGroup> <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" /> </ItemGroup> - <ItemGroup> - <Folder Include="Loader\Hql\" /> - </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-27 06:53:42
|
Revision: 4535 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4535&view=rev Author: RicBrown Date: 2009-06-27 06:53:39 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Added first cut of ICriteria<T> alias syntax using a reference variable. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -36,6 +36,13 @@ ICriteria<T> Where(Expression<Func<T, bool>> expression); /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> Where(Expression<Func<bool>> expression); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> /// <param name="results">The list filled with the results.</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -37,6 +37,12 @@ return this; } + ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); + return this; + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -16,19 +16,48 @@ { [Test] - public void Equality() + public void SimpleCriterion_NoAlias() { ICriteria expected = CreateTestCriteria(typeof(Person)) .Add(Restrictions.Eq("Name", "test name")); ICriteria<Person> actual = - CreateTestCriteria<Person>() + CreateTestQueryOver<Person>() .And(p => p.Name == "test name"); AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Where_BehavesTheSameAs_And() + { + Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>) + CreateTestQueryOver<Person>() + .And(p => p.Name == "test name"); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); + } + + [Test] + public void SimpleCriterion_AliasReferenceSyntax() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .Add(Restrictions.Eq("personAlias.Name", "test name")); + + Person personAlias = null; + ICriteria<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq.Expressions; using System.Reflection; using NHibernate.Criterion; @@ -29,11 +30,17 @@ return new CriteriaImpl(persistentClass, alias, null); } - protected ICriteria<T> CreateTestCriteria<T>() + protected ICriteria<T> CreateTestQueryOver<T>() { return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), null)); } + protected ICriteria<T> CreateTestQueryOver<T>(Expression<Func<object>> alias) + { + string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); + return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), aliasContainer, null)); + } + protected void AssertCriteriaAreEqual(ICriteria expected, ICriteria actual) { AssertObjectsAreEqual(expected, actual); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-27 07:07:51
|
Revision: 4536 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4536&view=rev Author: RicBrown Date: 2009-06-27 07:07:50 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Added overload for And() with same semantics as Where(). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -29,6 +29,13 @@ ICriteria<T> And(Expression<Func<T, bool>> expression); /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> And(Expression<Func<bool>> expression); + + /// <summary> /// Identical semantics to Add() to allow more readable queries /// </summary> /// <param name="expression">Lambda expression</param> @@ -36,7 +43,7 @@ ICriteria<T> Where(Expression<Func<T, bool>> expression); /// <summary> - /// Add criterion expressed as a lambda expression + /// Identical semantics to Add() to allow more readable queries /// </summary> /// <param name="expression">Lambda expression</param> /// <returns>criteria instance</returns> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -27,20 +27,22 @@ ICriteria<T> ICriteria<T>.And(Expression<Func<T, bool>> expression) { - _criteria.Add(expression); - return this; + return Add(expression); } + ICriteria<T> ICriteria<T>.And(Expression<Func<bool>> expression) + { + return Add(expression); + } + ICriteria<T> ICriteria<T>.Where(Expression<Func<T, bool>> expression) { - _criteria.Add(expression); - return this; + return Add(expression); } ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression) { - _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); - return this; + return Add(expression); } IList<T> ICriteria<T>.List() @@ -48,6 +50,18 @@ return _criteria.List<T>(); } + private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); + return this; + } + + private CriteriaImpl<T> Add(Expression<Func<bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); + return this; + } + } } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -32,12 +32,15 @@ [Test] public void Where_BehavesTheSameAs_And() { + Person personAlias = null; Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>) - CreateTestQueryOver<Person>() + CreateTestQueryOver<Person>(() => personAlias) + .And(() => personAlias.Name == "test name") .And(p => p.Name == "test name"); ICriteria<Person> actual = - CreateTestQueryOver<Person>() + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name") .Where(p => p.Name == "test name"); AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-27 14:50:59
|
Revision: 4537 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4537&view=rev Author: fabiomaulo Date: 2009-06-27 14:50:53 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Fixed TYPO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,7 +3,7 @@ { public interface IBatcherConfiguration { - IBatcherConfiguration Trough<TBatcher>() where TBatcher : IBatcherFactory; + IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory; IDbIntegrationConfiguration Each(short batchSize); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,7 +3,7 @@ { public interface ICacheConfiguration { - ICacheConfiguration Trough<TProvider>() where TProvider : ICacheProvider; + ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider; ICacheConfiguration PrefixingRegionsWith(string regionPrefix); ICacheConfiguration UsingMinimalPuts(); IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,6 +3,6 @@ { public interface ICollectionFactoryConfiguration { - IFluentSessionFactoryConfiguration Trough<TCollecionsFactory>() where TCollecionsFactory : ICollectionTypeFactory; + IFluentSessionFactoryConfiguration Through<TCollecionsFactory>() where TCollecionsFactory : ICollectionTypeFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -5,7 +5,7 @@ { ICommandsConfiguration Preparing(); ICommandsConfiguration WithTimeout(int seconds); - ICommandsConfiguration ConvertingExceptionsTrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; + ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; ICommandsConfiguration AutoCommentingSql(); IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions); IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions(); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -7,8 +7,8 @@ { public interface IConnectionConfiguration { - IConnectionConfiguration Trough<TProvider>() where TProvider : IConnectionProvider; - IConnectionConfiguration Through<TDriver>() where TDriver : IDriver; + IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider; + IConnectionConfiguration By<TDriver>() where TDriver : IDriver; IConnectionConfiguration With(IsolationLevel level); IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode); IDbIntegrationConfiguration Using(string connectionString); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -2,7 +2,7 @@ { public interface IMappingsConfiguration { - IMappingsConfiguration UsingDefaultSchema(string defaultSchemaName); IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName); + IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -4,6 +4,6 @@ public interface IProxyConfiguration { IProxyConfiguration DisableValidation(); - IFluentSessionFactoryConfiguration Trough<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; + IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -4,6 +4,6 @@ { public interface IQueryCacheConfiguration { - ICacheConfiguration Trough<TFactory>() where TFactory : IQueryCache; + ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,6 +3,6 @@ { public interface ITransactionConfiguration { - IDbIntegrationConfiguration Trough<TFactory>() where TFactory : ITransactionFactory; + IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -1,5 +1,4 @@ using System.Data; -using System.Data.Common; using System.Data.SqlClient; using NHibernate.AdoNet; using NHibernate.ByteCode.LinFu; @@ -21,21 +20,37 @@ // Using the Configuration class the user can add mappings and configure listeners IFluentSessionFactoryConfiguration sfc= null; sfc.Named("SomeName") + .Caching + .Through<HashtableCacheProvider>() + .PrefixingRegionsWith("xyz") + .Queries + .Through<StandardQueryCache>() + .UsingMinimalPuts() + .WithDefaultExpiration(15) + .GeneratingCollections + .Through<DefaultCollectionTypeFactory>() + .Proxy + .DisableValidation() + .Through<ProxyFactoryFactory>() + .ParsingHqlThrough<ClassicQueryTranslatorFactory>() + .Mapping + .UsingDefaultCatalog("MyCatalog") + .UsingDefaultSchema("MySche") .Integrate .Using<MsSql2000Dialect>() .AutoQuoteKeywords() .BatchingQueries - .Trough<SqlClientBatchingBatcherFactory>() + .Through<SqlClientBatchingBatcherFactory>() .Each(10) .Connected - .Trough<DebugConnectionProvider>() - .Through<SqlClientDriver>() + .Through<DebugConnectionProvider>() + .By<SqlClientDriver>() .Releasing(ConnectionReleaseMode.AfterTransaction) .With(IsolationLevel.ReadCommitted) .Using("The connection string but it has some overload") .CreateCommands .AutoCommentingSql() - .ConvertingExceptionsTrough<SQLStateConverter>() + .ConvertingExceptionsThrough<SQLStateConverter>() .Preparing() .WithTimeout(10) .WithMaximumDepthOfOuterJoinFetching(10) @@ -43,23 +58,7 @@ .Schema .Validating() ; - sfc.Caching - .Trough<HashtableCacheProvider>() - .PrefixingRegionsWith("xyz") - .Queries - .Trough<StandardQueryCache>() - .UsingMinimalPuts() - .WithDefaultExpiration(15) - .GeneratingCollections - .Trough<DefaultCollectionTypeFactory>() - .Proxy - .DisableValidation() - .Trough<ProxyFactoryFactory>() - .ParsingHqlThrough<ClassicQueryTranslatorFactory>() - .Mapping - .UsingDefaultCatalog("MyCatalog") - .UsingDefaultSchema("MySche") - ; + } public void ProofOfConceptMinimalConfiguration() @@ -69,7 +68,7 @@ // The place where put default properties values is the Dialect itself. IFluentSessionFactoryConfiguration sfc = null; sfc - .Proxy.Trough<ProxyFactoryFactory>() + .Proxy.Through<ProxyFactoryFactory>() .Integrate .Using<MsSql2005Dialect>() .Connected This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-06-28 14:56:23
|
Revision: 4540 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4540&view=rev Author: ayenderahien Date: 2009-06-28 13:57:21 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Merging from 2.1.x - rest of commit More fixes for NH 1850 Will now also report timing for batched statements execution Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Property Changed: ---------------- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/ Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -397,7 +397,7 @@ InvalidateBatchCommand(); try { - DoExecuteBatch(ps); + ExecuteBatchWithTiming(ps); } finally { @@ -406,12 +406,27 @@ } } + protected void ExecuteBatchWithTiming(IDbCommand ps) + { + Stopwatch duration = null; + if (log.IsDebugEnabled) + duration = Stopwatch.StartNew(); + var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch; + DoExecuteBatch(ps); + if (log.IsDebugEnabled && duration != null) + log.DebugFormat("ExecuteBatch for {0} statements took {1} ms", + countBeforeExecutingBatch, + duration.ElapsedMilliseconds); + } + /// <summary> /// /// </summary> /// <param name="ps"></param> protected abstract void DoExecuteBatch(IDbCommand ps); + protected abstract int CountOfStatementsInCurrentBatch { get; } + /// <summary> /// Gets or sets the size of the batch, this can change dynamically by /// calling the session's SetBatchSize. Modified: trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -9,7 +9,7 @@ /// An implementation of the <see cref="IBatcher" /> /// interface that does no batching. /// </summary> - internal class NonBatchingBatcher : AbstractBatcher + public class NonBatchingBatcher : AbstractBatcher { /// <summary> /// Initializes a new instance of the <see cref="NonBatchingBatcher"/> class. @@ -50,7 +50,12 @@ { } + protected override int CountOfStatementsInCurrentBatch + { + get { return 1; } + } + public override int BatchSize { get { return 1; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -72,7 +72,7 @@ if (countOfCommands >= batchSize) { - DoExecuteBatch(currentBatch); + ExecuteBatchWithTiming(currentBatch); } } @@ -108,6 +108,11 @@ } } + protected override int CountOfStatementsInCurrentBatch + { + get { return countOfCommands; } + } + private void SetObjectParam(Object obj, string paramName, object paramValue) { System.Type objType = obj.GetType(); Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -4,10 +4,12 @@ namespace NHibernate.AdoNet { + using System; + /// <summary> /// Summary description for SqlClientBatchingBatcher. /// </summary> - internal class SqlClientBatchingBatcher : AbstractBatcher + public class SqlClientBatchingBatcher : AbstractBatcher { private int batchSize; private int totalExpectedRowsAffected; @@ -32,6 +34,11 @@ set { batchSize = value; } } + protected override int CountOfStatementsInCurrentBatch + { + get { return currentBatch.CountOfCommands; } + } + public override void AddToBatch(IExpectation expectation) { totalExpectedRowsAffected += expectation.ExpectedRowCount; @@ -39,7 +46,7 @@ string lineWithParameters = null; var sqlStatementLogger = Factory.Settings.SqlStatementLogger; - if (sqlStatementLogger.IsDebugEnabled) + if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled) { lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate); var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic); @@ -57,13 +64,13 @@ if (currentBatch.CountOfCommands >= batchSize) { - DoExecuteBatch(batchUpdate); + ExecuteBatchWithTiming(batchUpdate); } } protected override void DoExecuteBatch(IDbCommand ps) { - log.Debug("Executing batch"); + log.DebugFormat("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513 + /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513,4537-4538 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-28 21:59:30
|
Revision: 4541 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4541&view=rev Author: RicBrown Date: 2009-06-28 21:59:29 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Added creation of sub-criteria to ICriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -12,10 +12,10 @@ /// </summary> /// <remarks> /// <code> - /// IList<Cat> cats = session.QueryOver<Cat>() - /// .Add( c => c.Name == "Tigger" ) - /// .Add( c => c.Weight > minWeight ) ) - /// .List(); + /// IList<Cat> cats = session.QueryOver<Cat>() + /// .Add( c => c.Name == "Tigger" ) + /// .Add( c => c.Weight > minWeight ) ) + /// .List(); /// </code> /// </remarks> public interface ICriteria<T> @@ -50,6 +50,23 @@ ICriteria<T> Where(Expression<Func<bool>> expression); /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// </summary> + /// <typeparam name="U">Type of sub-criteria</typeparam> + /// <param name="expression">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + ICriteria<U> Join<U>(Expression<Func<T, U>> expression); + + /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// specifying a collection for the join. + /// </summary> + /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> + /// <param name="expression">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + ICriteria<U> Join<U>(Expression<Func<T, IEnumerable<U>>> expression); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> /// <param name="results">The list filled with the results.</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -45,6 +45,20 @@ return Add(expression); } + ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, U>> expression) + { + return new CriteriaImpl<U>( + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(expression.Body))); + } + + ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, IEnumerable<U>>> expression) + { + return new CriteriaImpl<U>( + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(expression.Body))); + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -61,6 +61,38 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void SubCriteria_Join_ToOne() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Father") + .Add(Expression.Eq("Name", "test name")); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Join(p => p.Father) // sub-criteria + .Where(f => f.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void SubCriteria_Join_ToMany() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Children") + .Add(Expression.Eq("Nickname", "test name")); + + ICriteria<Child> actual = + CreateTestQueryOver<Person>() + .Join<Child>(p => p.Children) // sub-criteria + .Where(c => c.Nickname == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -7,14 +7,18 @@ public class Person { - public virtual int Id { get; set; } - public virtual string Name { get; set; } - public virtual int Age { get; set; } + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual int Age { get; set; } + public virtual Person Father { get; set; } + + public virtual IEnumerable<Child> Children { get; set; } } public class Child { - public virtual int Id { get; set; } + public virtual int Id { get; set; } + public virtual string Nickname { get; set; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 18:11:02
|
Revision: 4542 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4542&view=rev Author: RicBrown Date: 2009-06-29 18:10:53 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Reverted changes to ICriteria to keep ICriteria<T> separate (for now at least). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteria.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq.Expressions; using NHibernate.Criterion; using NHibernate.SqlCommand; using NHibernate.Transform; @@ -10,7 +9,7 @@ { /// <summary> /// Criteria is a simplified API for retrieving entities by composing - /// <see cref="Criterion.Expression" /> objects. + /// <see cref="Expression" /> objects. /// </summary> /// <remarks> /// <para> @@ -19,7 +18,7 @@ /// </para> /// <para> /// The Session is a factory for ICriteria. Expression instances are usually obtained via - /// the factory methods on <see cref="Criterion.Expression" />. eg: + /// the factory methods on <see cref="Expression" />. eg: /// </para> /// <code> /// IList cats = session.CreateCriteria(typeof(Cat)) @@ -83,14 +82,6 @@ ICriteria Add(ICriterion expression); /// <summary> - /// Add criterion expressed as a lambda expression - /// </summary> - /// <typeparam name="T">Type (same as criteria type)</typeparam> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria Add<T>(Expression<Func<T, bool>> expression); - - /// <summary> /// An an Order to the result set /// </summary> /// <param name="order"></param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq.Expressions; using System.Text; using NHibernate.Criterion; using NHibernate.Engine; @@ -232,11 +231,6 @@ return this; } - public ICriteria Add<T>(Expression<Func<T, bool>> expression) - { - return Add(ExpressionProcessor.ProcessExpression<T>(expression)); - } - public IList List() { ArrayList results = new ArrayList(); @@ -673,11 +667,6 @@ return this; } - public ICriteria Add<T>(Expression<Func<T, bool>> expression) - { - return Add(ExpressionProcessor.ProcessExpression<T>(expression)); - } - public ICriteria AddOrder(Order order) { root.orderEntries.Add(new OrderEntry(order, this)); Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,34 +0,0 @@ -using System; -using System.Collections; - -using NUnit.Framework; - -using NHibernate.Criterion; -using NHibernate.Transform; -using NHibernate.Type; -using NHibernate.Util; - -namespace NHibernate.Test.Criteria.Lambda -{ - - [TestFixture] - public class CriteriaFixture : LambdaFixtureBase - { - - [Test] - public void Equality() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .Add(Restrictions.Eq("Name", "test name")); - - ICriteria actual = - CreateTestCriteria(typeof(Person)) - .Add<Person>(p => p.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - } - -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -43,30 +43,6 @@ } [Test] - public void ICriteria_SimpleCriterion() - { - using (ISession s = OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - s.Save(new Person() { Name = "test person 1" }); - s.Save(new Person() { Name = "test person 2" }); - s.Save(new Person() { Name = "test person 3" }); - - t.Commit(); - } - - using (ISession s = OpenSession()) - { - IList<Person> actual = - s.CreateCriteria(typeof(Person)) - .Add<Person>(p => p.Name == "test person 2") - .List<Person>(); - - Assert.That(actual.Count, Is.EqualTo(1)); - } - } - - [Test] public void ICriteriaOfT_SimpleCriterion() { using (ISession s = OpenSession()) Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 18:10:53 UTC (rev 4542) @@ -145,7 +145,6 @@ <Compile Include="Criteria\DetachedCriteriaSerializable.cs" /> <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> - <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 18:52:41
|
Revision: 4543 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4543&view=rev Author: RicBrown Date: 2009-06-29 18:52:24 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added first cut of Join() to ICriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -53,23 +53,31 @@ /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> - /// <param name="expression">Lambda expression returning association path</param> + /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - ICriteria<U> Join<U>(Expression<Func<T, U>> expression); + ICriteria<U> JoinWalk<U>(Expression<Func<T, U>> path); /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// specifying a collection for the join. /// </summary> /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> - /// <param name="expression">Lambda expression returning association path</param> + /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - ICriteria<U> Join<U>(Expression<Func<T, IEnumerable<U>>> expression); + ICriteria<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path); /// <summary> + /// Join an association, assigning an alias to the joined entity + /// </summary> + /// <param name="path">Lambda expression returning association path</param> + /// <param name="alias">Lambda expression returning alias reference</param> + /// <returns>criteria instance</returns> + ICriteria<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> - /// <param name="results">The list filled with the results.</param> + /// <returns>The list filled with the results.</returns> IList<T> List(); } Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; +using NHibernate.SqlCommand; namespace NHibernate.Impl { @@ -45,25 +46,39 @@ return Add(expression); } - ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, U>> expression) + ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, U>> path) { return new CriteriaImpl<U>( _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(expression.Body))); + ExpressionProcessor.FindMemberExpression(path.Body))); } - ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, IEnumerable<U>>> expression) + ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) { return new CriteriaImpl<U>( _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(expression.Body))); + ExpressionProcessor.FindMemberExpression(path.Body))); } + ICriteria<T> ICriteria<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + { + return AddAlias( + ExpressionProcessor.FindMemberExpression(path.Body), + ExpressionProcessor.FindMemberExpression(alias.Body), + JoinType.InnerJoin); + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); } + private CriteriaImpl<T> AddAlias(string path, string alias, JoinType joinType) + { + _criteria.CreateAlias(path, alias, joinType); + return this; + } + private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression) { _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -62,7 +62,7 @@ } [Test] - public void SubCriteria_Join_ToOne() + public void SubCriteria_JoinWalk_ToOne() { ICriteria expected = CreateTestCriteria(typeof(Person)) @@ -71,14 +71,14 @@ ICriteria<Person> actual = CreateTestQueryOver<Person>() - .Join(p => p.Father) // sub-criteria + .JoinWalk(p => p.Father) // sub-criteria .Where(f => f.Name == "test name"); AssertCriteriaAreEqual(expected, actual); } [Test] - public void SubCriteria_Join_ToMany() + public void SubCriteria_JoinWalk_ToMany() { ICriteria expected = CreateTestCriteria(typeof(Person)) @@ -87,12 +87,30 @@ ICriteria<Child> actual = CreateTestQueryOver<Person>() - .Join<Child>(p => p.Children) // sub-criteria + .JoinWalk<Child>(p => p.Children) // sub-criteria .Where(c => c.Nickname == "test name"); AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Alias_Join() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .CreateAlias("Children", "childAlias"); + + Person fatherAlias = null; + Child childAlias = null; + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Join(p => p.Father, () => fatherAlias) + .Join(p => p.Children, () => childAlias); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 19:38:36
|
Revision: 4544 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4544&view=rev Author: RicBrown Date: 2009-06-29 19:38:33 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added first cut of DetachedCriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -95,6 +95,11 @@ return new DetachedCriteria(entityName, alias); } + public static DetachedCriteria<T> QueryOver<T>() + { + return new DetachedCriteria<T>(new DetachedCriteria(typeof(T))); + } + public DetachedCriteria Add(ICriterion criterion) { criteria.Add(criterion); Added: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -0,0 +1,53 @@ + +using System; +using System.Linq.Expressions; + +using NHibernate.Impl; + +namespace NHibernate.Criterion +{ + + /// <summary> + /// Some applications need to create criteria queries in "detached + /// mode", where the Hibernate session is not available. This class + /// may be instantiated anywhere, and then a <c>ICriteria</c> + /// may be obtained by passing a session to + /// <c>GetExecutableCriteria()</c>. All methods have the + /// same semantics and behavior as the corresponding methods of the + /// <c>ICriteria<T></c> interface. + /// </summary> + [Serializable] + public class DetachedCriteria<T> + { + + private DetachedCriteria _criteria; + + protected internal DetachedCriteria(DetachedCriteria detachedCriteria) + { + _criteria = detachedCriteria; + } + + public DetachedCriteria<T> And(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + public DetachedCriteria<T> Where(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + private DetachedCriteria<T> Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); + return this; + } + + public static implicit operator DetachedCriteria(DetachedCriteria<T> detachedCriteria) + { + return detachedCriteria._criteria; + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 19:38:33 UTC (rev 4544) @@ -477,6 +477,7 @@ <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> + <Compile Include="Criterion\DetachedCriteriaOfT.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -0,0 +1,48 @@ +using System; +using System.Collections; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.Transform; +using NHibernate.Type; +using NHibernate.Util; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class DetachedCriteriaOfTFixture : LambdaFixtureBase + { + + [Test] + public void SimpleCriterion_NoAlias() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Restrictions.Eq("Name", "test name")); + + DetachedCriteria<Person> actual = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void Where_BehavesTheSameAs_And() + { + DetachedCriteria<Person> expected = + DetachedCriteria.QueryOver<Person>() + .And(p => p.Name == "test name"); + + DetachedCriteria<Person> actual = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 19:38:33 UTC (rev 4544) @@ -146,6 +146,7 @@ <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> + <Compile Include="Criteria\Lambda\DetachedCriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 19:46:12
|
Revision: 4545 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4545&view=rev Author: RicBrown Date: 2009-06-29 19:46:11 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added integration test for DetachedCriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:38:33 UTC (rev 4544) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:46:11 UTC (rev 4545) @@ -27,6 +27,14 @@ _criteria = detachedCriteria; } + /// <summary> + /// Get an executable instance of <c>Criteria<T></c>, + /// to actually run the query.</summary> + public ICriteria<T> GetExecutableCriteria(ISession session) + { + return new CriteriaImpl<T>(_criteria.GetExecutableCriteria(session)); + } + public DetachedCriteria<T> And(Expression<Func<T, bool>> expression) { return Add(expression); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:38:33 UTC (rev 4544) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:46:11 UTC (rev 4545) @@ -67,6 +67,30 @@ } } + [Test] + public void DetachedCriteriaOfT_SimpleCriterion() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1", Age = 20 }); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + var personQuery = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test person 1"); + + IList<Person> actual = + personQuery.GetExecutableCriteria(s) + .List(); + + Assert.That(actual[0].Age, Is.EqualTo(20)); + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 20:57:51
|
Revision: 4548 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4548&view=rev Author: RicBrown Date: 2009-06-29 20:56:51 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added handling of multiple ICriterion in a single expression. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -278,12 +278,46 @@ return criterion; } + private static ICriterion ProcessAndExpression(BinaryExpression expression) + { + return + NHibernate.Criterion.Restrictions.And( + ProcessExpression(expression.Left), + ProcessExpression(expression.Right)); + } + + private static ICriterion ProcessOrExpression(BinaryExpression expression) + { + return + NHibernate.Criterion.Restrictions.Or( + ProcessExpression(expression.Left), + ProcessExpression(expression.Right)); + } + private static ICriterion ProcessBinaryExpression(BinaryExpression expression) { - if (IsMemberExpression(expression.Right)) - return ProcessMemberExpression(expression); - else - return ProcessSimpleExpression(expression); + switch (expression.NodeType) + { + case ExpressionType.AndAlso: + return ProcessAndExpression(expression); + + case ExpressionType.OrElse: + return ProcessOrExpression(expression); + + case ExpressionType.Equal: + case ExpressionType.NotEqual: + case ExpressionType.GreaterThan: + case ExpressionType.GreaterThanOrEqual: + case ExpressionType.LessThan: + case ExpressionType.LessThanOrEqual: + if (IsMemberExpression(expression.Right)) + return ProcessMemberExpression(expression); + else + return ProcessSimpleExpression(expression); + + default: + throw new Exception("Unhandled binary expression: " + expression.NodeType + ", " + expression.ToString()); + } } private static ICriterion ProcessBooleanExpression(Expression expression) @@ -306,16 +340,19 @@ throw new Exception("Could not determine member type from " + expression.ToString()); } - private static ICriterion ProcessLambdaExpression(LambdaExpression expression) + private static ICriterion ProcessExpression(Expression expression) { - var body = expression.Body; - - if (body is BinaryExpression) - return ProcessBinaryExpression((BinaryExpression)body); + if (expression is BinaryExpression) + return ProcessBinaryExpression((BinaryExpression)expression); else - return ProcessBooleanExpression((Expression)body); + return ProcessBooleanExpression((Expression)expression); } + private static ICriterion ProcessLambdaExpression(LambdaExpression expression) + { + return ProcessExpression(expression.Body); + } + /// <summary> /// Convert a lambda expression to NHibernate ICriterion /// </summary> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -64,6 +64,24 @@ } [Test] + public void MultipleCriterionExpression() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.And( + Restrictions.Eq("Name", "test name"), + Restrictions.Or( + Restrictions.Gt("Age", 21), + Restrictions.Eq("HasCar", true)))); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test name" && (p.Age > 21 || p.HasCar)); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] public void Where_BehavesTheSameAs_And() { Person personAlias = null; Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -11,6 +11,7 @@ public virtual string Name { get; set; } public virtual int Age { get; set; } public virtual int Height { get; set; } + public virtual bool HasCar { get; set; } public virtual Person Father { get; set; } public virtual IEnumerable<Child> Children { get; set; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-30 17:32:18
|
Revision: 4549 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4549&view=rev Author: fabiomaulo Date: 2009-06-30 17:32:16 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Minor (added one entry point for fluent conf) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-06-30 17:32:16 UTC (rev 4549) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.Loquacious +{ + public static class ConfigurationExtensions + { + public static IFluentSessionFactoryConfiguration SessionFactory(this Configuration configuration) + { + return null; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 20:56:51 UTC (rev 4548) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-30 17:32:16 UTC (rev 4549) @@ -459,6 +459,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-29 20:56:51 UTC (rev 4548) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-30 17:32:16 UTC (rev 4549) @@ -3,6 +3,7 @@ using NHibernate.AdoNet; using NHibernate.ByteCode.LinFu; using NHibernate.Cache; +using NHibernate.Cfg; using NHibernate.Cfg.Loquacious; using NHibernate.Dialect; using NHibernate.Driver; @@ -18,8 +19,8 @@ { // Here I'm configuring near all properties outside the scope of Configuration class // Using the Configuration class the user can add mappings and configure listeners - IFluentSessionFactoryConfiguration sfc= null; - sfc.Named("SomeName") + var cfg = new Configuration(); + cfg.SessionFactory().Named("SomeName") .Caching .Through<HashtableCacheProvider>() .PrefixingRegionsWith("xyz") @@ -66,8 +67,8 @@ // This is a possible minimal configuration // in this case we must define best default properties for each dialect // The place where put default properties values is the Dialect itself. - IFluentSessionFactoryConfiguration sfc = null; - sfc + var cfg = new Configuration(); + cfg.SessionFactory() .Proxy.Through<ProxyFactoryFactory>() .Integrate .Using<MsSql2005Dialect>() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-01 16:31:21
|
Revision: 4551 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4551&view=rev Author: fabiomaulo Date: 2009-07-01 16:31:18 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Fluent configuration implemented Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -4,7 +4,7 @@ { public static IFluentSessionFactoryConfiguration SessionFactory(this Configuration configuration) { - return null; + return new FluentSessionFactoryConfiguration(configuration); } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -0,0 +1,470 @@ +using System.Data; +using System.Data.Common; +using NHibernate.AdoNet; +using NHibernate.Bytecode; +using NHibernate.Cache; +using NHibernate.Connection; +using NHibernate.Driver; +using NHibernate.Exceptions; +using NHibernate.Hql; +using NHibernate.Transaction; + +namespace NHibernate.Cfg.Loquacious +{ + internal class FluentSessionFactoryConfiguration : IFluentSessionFactoryConfiguration + { + private readonly Configuration configuration; + + public FluentSessionFactoryConfiguration(Configuration configuration) + { + this.configuration = configuration; + Integrate = new DbIntegrationConfiguration(configuration); + Caching = new CacheConfiguration(this); + Proxy = new ProxyConfiguration(this); + GeneratingCollections = new CollectionFactoryConfiguration(this); + Mapping = new MappingsConfiguration(this); + } + + internal Configuration Configuration + { + get { return configuration; } + } + + #region Implementation of IFluentSessionFactoryConfiguration + + public IFluentSessionFactoryConfiguration Named(string sessionFactoryName) + { + configuration.SetProperty(Environment.SessionFactoryName, sessionFactoryName); + return this; + } + + public IDbIntegrationConfiguration Integrate { get; private set; } + + public ICacheConfiguration Caching { get; private set; } + + public IFluentSessionFactoryConfiguration GenerateStatistics() + { + configuration.SetProperty(Environment.GenerateStatistics, "true"); + return this; + } + + public IFluentSessionFactoryConfiguration Using(EntityMode entityMode) + { + configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(entityMode)); + return this; + } + + public IFluentSessionFactoryConfiguration ParsingHqlThrough<TQueryTranslator>() + where TQueryTranslator : IQueryTranslatorFactory + { + configuration.SetProperty(Environment.QueryTranslator, typeof (TQueryTranslator).AssemblyQualifiedName); + return this; + } + + public IProxyConfiguration Proxy { get; private set; } + public ICollectionFactoryConfiguration GeneratingCollections { get; private set; } + public IMappingsConfiguration Mapping { get; private set; } + + #endregion + } + + internal class DbIntegrationConfiguration : IDbIntegrationConfiguration + { + private readonly Configuration configuration; + + public DbIntegrationConfiguration(Configuration configuration) + { + this.configuration = configuration; + Connected = new ConnectionConfiguration(this); + BatchingQueries = new BatcherConfiguration(this); + Transactions = new TransactionConfiguration(this); + CreateCommands = new CommandsConfiguration(this); + Schema = new DbSchemaIntegrationConfiguration(this); + } + + public Configuration Configuration + { + get { return configuration; } + } + + #region Implementation of IDbIntegrationConfiguration + + public IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect + { + configuration.SetProperty(Environment.Dialect, typeof (TDialect).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration DisableKeywordsAutoImport() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "none"); + return this; + } + + public IDbIntegrationConfiguration AutoQuoteKeywords() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + return this; + } + + public IDbIntegrationConfiguration LogSqlInConsole() + { + configuration.SetProperty(Environment.ShowSql, "true"); + return this; + } + + public IDbIntegrationConfiguration DisableLogFormatedSql() + { + configuration.SetProperty(Environment.FormatSql, "false"); + return this; + } + + public IConnectionConfiguration Connected { get; private set; } + public IBatcherConfiguration BatchingQueries { get; private set; } + public ITransactionConfiguration Transactions { get; private set; } + + public ICommandsConfiguration CreateCommands { get; private set; } + + public IDbSchemaIntegrationConfiguration Schema { get; private set; } + + #endregion + } + + internal class DbSchemaIntegrationConfiguration : IDbSchemaIntegrationConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public DbSchemaIntegrationConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IDbSchemaIntegrationConfiguration + + public IDbIntegrationConfiguration Recreating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create-drop"); + return dbc; + } + + public IDbIntegrationConfiguration Creating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create"); + return dbc; + } + + public IDbIntegrationConfiguration Updating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "update"); + return dbc; + } + + public IDbIntegrationConfiguration Validating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "validate"); + return dbc; + } + + #endregion + } + + internal class CommandsConfiguration : ICommandsConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public CommandsConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ICommandsConfiguration + + public ICommandsConfiguration Preparing() + { + dbc.Configuration.SetProperty(Environment.PrepareSql, "true"); + return this; + } + + public ICommandsConfiguration WithTimeout(int seconds) + { + dbc.Configuration.SetProperty(Environment.CommandTimeout, seconds.ToString()); + return this; + } + + public ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() + where TExceptionConverter : ISQLExceptionConverter + { + dbc.Configuration.SetProperty(Environment.SqlExceptionConverter, typeof (TExceptionConverter).AssemblyQualifiedName); + return this; + } + + public ICommandsConfiguration AutoCommentingSql() + { + dbc.Configuration.SetProperty(Environment.UseSqlComments, "true"); + return this; + } + + public IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions) + { + dbc.Configuration.SetProperty(Environment.QuerySubstitutions, csvQuerySubstitutions); + return dbc; + } + + public IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions() + { + return dbc; + } + + public ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth) + { + dbc.Configuration.SetProperty(Environment.MaxFetchDepth, maxFetchDepth.ToString()); + return this; + } + + #endregion + } + + internal class TransactionConfiguration : ITransactionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public TransactionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ITransactionConfiguration + + public IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory + { + dbc.Configuration.SetProperty(Environment.TransactionStrategy, typeof (TFactory).AssemblyQualifiedName); + return dbc; + } + + #endregion + } + + internal class BatcherConfiguration : IBatcherConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public BatcherConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IBatcherConfiguration + + public IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory + { + dbc.Configuration.SetProperty(Environment.BatchStrategy, typeof (TBatcher).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration Each(short batchSize) + { + dbc.Configuration.SetProperty(Environment.BatchSize, batchSize.ToString()); + return dbc; + } + + #endregion + } + + internal class ConnectionConfiguration : IConnectionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public ConnectionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IConnectionConfiguration + + public IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider + { + dbc.Configuration.SetProperty(Environment.ConnectionProvider, typeof (TProvider).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration By<TDriver>() where TDriver : IDriver + { + dbc.Configuration.SetProperty(Environment.ConnectionDriver, typeof (TDriver).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration With(IsolationLevel level) + { + dbc.Configuration.SetProperty(Environment.Isolation, level.ToString()); + return this; + } + + public IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode) + { + dbc.Configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(releaseMode)); + return this; + } + + public IDbIntegrationConfiguration Using(string connectionString) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionString); + return dbc; + } + + public IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionStringBuilder.ConnectionString); + return dbc; + } + + public IDbIntegrationConfiguration ByAppConfing(string connectionStringName) + { + dbc.Configuration.SetProperty(Environment.ConnectionStringName, connectionStringName); + return dbc; + } + + #endregion + } + + internal class CacheConfiguration : ICacheConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public CacheConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + Queries = new QueryCacheConfiguration(this); + } + + internal Configuration Configuration + { + get { return fc.Configuration; } + } + + #region Implementation of ICacheConfiguration + + public ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider + { + fc.Configuration.SetProperty(Environment.CacheProvider, typeof (TProvider).AssemblyQualifiedName); + return this; + } + + public ICacheConfiguration PrefixingRegionsWith(string regionPrefix) + { + fc.Configuration.SetProperty(Environment.CacheRegionPrefix, regionPrefix); + return this; + } + + public ICacheConfiguration UsingMinimalPuts() + { + fc.Configuration.SetProperty(Environment.UseMinimalPuts, "true"); + return this; + } + + public IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds) + { + fc.Configuration.SetProperty(Environment.CacheDefaultExpiration, seconds.ToString()); + return fc; + } + + public IQueryCacheConfiguration Queries { get; private set; } + + #endregion + } + + internal class QueryCacheConfiguration : IQueryCacheConfiguration + { + private readonly CacheConfiguration cc; + + public QueryCacheConfiguration(CacheConfiguration cc) + { + this.cc = cc; + } + + #region Implementation of IQueryCacheConfiguration + + public ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache + { + cc.Configuration.SetProperty(Environment.QueryCacheFactory, typeof (TFactory).AssemblyQualifiedName); + return cc; + } + + #endregion + } + + internal class ProxyConfiguration : IProxyConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public ProxyConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IProxyConfiguration + + public IProxyConfiguration DisableValidation() + { + fc.Configuration.SetProperty(Environment.UseProxyValidator, "false"); + return this; + } + + public IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() + where TProxyFactoryFactory : IProxyFactoryFactory + { + fc.Configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof (TProxyFactoryFactory).AssemblyQualifiedName); + return fc; + } + + #endregion + } + + internal class CollectionFactoryConfiguration : ICollectionFactoryConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public CollectionFactoryConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of ICollectionFactoryConfiguration + + public IFluentSessionFactoryConfiguration Through<TCollecionsFactory>() + where TCollecionsFactory : ICollectionTypeFactory + { + fc.Configuration.SetProperty(Environment.CollectionTypeFactoryClass, + typeof (TCollecionsFactory).AssemblyQualifiedName); + return fc; + } + + #endregion + } + + internal class MappingsConfiguration : IMappingsConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public MappingsConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IMappingsConfiguration + + public IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName) + { + fc.Configuration.SetProperty(Environment.DefaultCatalog, defaultCatalogName); + return this; + } + + public IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName) + { + fc.Configuration.SetProperty(Environment.DefaultSchema, defaultSchemaName); + return fc; + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -95,7 +95,7 @@ } else { - releaseMode = ParseConnectionReleaseMode(releaseModeName); + releaseMode = ConnectionReleaseModeParser.Convert(releaseModeName); } settings.ConnectionReleaseMode = releaseMode; @@ -329,21 +329,6 @@ } } - private static ConnectionReleaseMode ParseConnectionReleaseMode(string name) - { - switch (name) - { - case "after_statement": - throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate"); - case "after_transaction": - return ConnectionReleaseMode.AfterTransaction; - case "on_close": - return ConnectionReleaseMode.OnClose; - default: - throw new HibernateException("could not determine appropriate connection release mode [" + name + "]"); - } - } - // visibility changed and static modifier added until complete H3.2 porting of SettingsFactory private static IQueryTranslatorFactory CreateQueryTranslatorFactory(IDictionary<string, string> properties) { Modified: trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -1,3 +1,5 @@ +using System; + namespace NHibernate { public enum ConnectionReleaseMode @@ -5,7 +7,38 @@ AfterStatement, AfterTransaction, OnClose + } - // Parse method moved to SettingsFactory + public static class ConnectionReleaseModeParser + { + public static ConnectionReleaseMode Convert(string value) + { + switch (value) + { + case "after_statement": + throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate"); + case "after_transaction": + return ConnectionReleaseMode.AfterTransaction; + case "on_close": + return ConnectionReleaseMode.OnClose; + default: + throw new HibernateException("could not determine appropriate connection release mode [" + value + "]"); + } + } + + public static string ToString(ConnectionReleaseMode value) + { + switch (value) + { + case ConnectionReleaseMode.AfterStatement: + return "after_statement"; + case ConnectionReleaseMode.AfterTransaction: + return "after_transaction" ; + case ConnectionReleaseMode.OnClose: + return "on_close"; + default: + throw new ArgumentOutOfRangeException("value"); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 16:31:18 UTC (rev 4551) @@ -460,6 +460,7 @@ <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> + <Compile Include="Cfg\Loquacious\FluentSessionFactoryConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -10,12 +10,15 @@ using NHibernate.Exceptions; using NHibernate.Hql.Classic; using NHibernate.Type; +using NUnit.Framework; namespace NHibernate.Test.CfgTest.Loquacious { + [TestFixture] public class ConfigurationFixture { - public void ProofOfConcept() + [Test] + public void CompleteConfiguration() { // Here I'm configuring near all properties outside the scope of Configuration class // Using the Configuration class the user can add mappings and configure listeners @@ -42,27 +45,67 @@ .AutoQuoteKeywords() .BatchingQueries .Through<SqlClientBatchingBatcherFactory>() - .Each(10) + .Each(15) .Connected .Through<DebugConnectionProvider>() .By<SqlClientDriver>() .Releasing(ConnectionReleaseMode.AfterTransaction) .With(IsolationLevel.ReadCommitted) - .Using("The connection string but it has some overload") + .Using("The connection string") .CreateCommands .AutoCommentingSql() .ConvertingExceptionsThrough<SQLStateConverter>() .Preparing() .WithTimeout(10) - .WithMaximumDepthOfOuterJoinFetching(10) + .WithMaximumDepthOfOuterJoinFetching(11) .WithHqlToSqlSubstitutions("true 1, false 0, yes 'Y', no 'N'") .Schema .Validating() ; + Assert.That(cfg.Properties[Environment.SessionFactoryName], Is.EqualTo("SomeName")); + Assert.That(cfg.Properties[Environment.CacheProvider], + Is.EqualTo(typeof(HashtableCacheProvider).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.CacheRegionPrefix], Is.EqualTo("xyz")); + Assert.That(cfg.Properties[Environment.QueryCacheFactory], + Is.EqualTo(typeof(StandardQueryCache).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.UseMinimalPuts], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.CacheDefaultExpiration], Is.EqualTo("15")); + Assert.That(cfg.Properties[Environment.CollectionTypeFactoryClass], + Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.UseProxyValidator], Is.EqualTo("false")); + Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], + Is.EqualTo(typeof(ProxyFactoryFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.QueryTranslator], + Is.EqualTo(typeof(ClassicQueryTranslatorFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog")); + Assert.That(cfg.Properties[Environment.DefaultSchema], Is.EqualTo("MySche")); + Assert.That(cfg.Properties[Environment.Dialect], + Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote")); + Assert.That(cfg.Properties[Environment.BatchStrategy], + Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.BatchSize], Is.EqualTo("15")); + Assert.That(cfg.Properties[Environment.ConnectionProvider], + Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ConnectionDriver], + Is.EqualTo(typeof(SqlClientDriver).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ReleaseConnections], + Is.EqualTo(ConnectionReleaseModeParser.ToString(ConnectionReleaseMode.AfterTransaction))); + Assert.That(cfg.Properties[Environment.Isolation], Is.EqualTo("ReadCommitted")); + Assert.That(cfg.Properties[Environment.ConnectionString], Is.EqualTo("The connection string")); + Assert.That(cfg.Properties[Environment.UseSqlComments], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.SqlExceptionConverter], + Is.EqualTo(typeof(SQLStateConverter).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.PrepareSql], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.CommandTimeout], Is.EqualTo("10")); + Assert.That(cfg.Properties[Environment.MaxFetchDepth], Is.EqualTo("11")); + Assert.That(cfg.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'")); + Assert.That(cfg.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate")); } - public void ProofOfConceptMinimalConfiguration() + [Test] + public void UseDbConfigurationStringBuilder() { // This is a possible minimal configuration // in this case we must define best default properties for each dialect @@ -79,6 +122,13 @@ InitialCatalog = "nhibernate", IntegratedSecurity = true }); + + Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], + Is.EqualTo(typeof (ProxyFactoryFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.Dialect], + Is.EqualTo(typeof(MsSql2005Dialect).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ConnectionString], + Is.EqualTo("Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True")); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-01 20:17:28
|
Revision: 4558 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4558&view=rev Author: ricbrown Date: 2009-07-01 20:17:23 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Move to single QueryOver class (instead of impl and detached-impl). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -95,11 +95,6 @@ return new DetachedCriteria(entityName, alias); } - public static DetachedCriteria<T> QueryOver<T>() - { - return new DetachedCriteria<T>(new DetachedCriteria(typeof(T))); - } - public DetachedCriteria Add(ICriterion criterion) { criteria.Add(criterion); Deleted: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -1,61 +0,0 @@ - -using System; -using System.Linq.Expressions; - -using NHibernate.Impl; - -namespace NHibernate.Criterion -{ - - /// <summary> - /// Some applications need to create criteria queries in "detached - /// mode", where the Hibernate session is not available. This class - /// may be instantiated anywhere, and then a <c>ICriteria</c> - /// may be obtained by passing a session to - /// <c>GetExecutableCriteria()</c>. All methods have the - /// same semantics and behavior as the corresponding methods of the - /// <c>ICriteria<T></c> interface. - /// </summary> - [Serializable] - public class DetachedCriteria<T> - { - - private DetachedCriteria _criteria; - - protected internal DetachedCriteria(DetachedCriteria detachedCriteria) - { - _criteria = detachedCriteria; - } - - /// <summary> - /// Get an executable instance of <c>Criteria<T></c>, - /// to actually run the query.</summary> - public ICriteria<T> GetExecutableCriteria(ISession session) - { - return new CriteriaImpl<T>(_criteria.GetExecutableCriteria(session)); - } - - public DetachedCriteria<T> And(Expression<Func<T, bool>> expression) - { - return Add(expression); - } - - public DetachedCriteria<T> Where(Expression<Func<T, bool>> expression) - { - return Add(expression); - } - - private DetachedCriteria<T> Add(Expression<Func<T, bool>> expression) - { - _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); - return this; - } - - public static implicit operator DetachedCriteria(DetachedCriteria<T> detachedCriteria) - { - return detachedCriteria._criteria; - } - - } - -} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs (from rev 4557, trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -0,0 +1,118 @@ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +using NHibernate.Impl; +using NHibernate.SqlCommand; + +namespace NHibernate.Criterion +{ + + /// <summary> + /// Implementation of the <see cref="ICriteria<T>"/> interface + /// </summary> + [Serializable] + public class QueryOver<T> : ICriteria<T> + { + + private ICriteria _criteria; + private CriteriaImpl _impl; + + public QueryOver() + { + _impl = new CriteriaImpl(typeof(T), null); + _criteria = _impl; + } + + public QueryOver(CriteriaImpl impl) + { + _impl = impl; + _criteria = impl; + } + + public QueryOver(CriteriaImpl rootImpl, ICriteria criteria) + { + _impl = rootImpl; + _criteria = criteria; + } + + public ICriteria UnderlyingCriteria + { + get { return _criteria; } + } + + public ICriteria<T> And(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + public ICriteria<T> And(Expression<Func<bool>> expression) + { + return Add(expression); + } + + public ICriteria<T> Where(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + public ICriteria<T> Where(Expression<Func<bool>> expression) + { + return Add(expression); + } + + public ICriteria<U> JoinWalk<U>(Expression<Func<T, U>> path) + { + return new QueryOver<U>(_impl, + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(path.Body))); + } + + public ICriteria<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) + { + return new QueryOver<U>(_impl, + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(path.Body))); + } + + public ICriteria<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + { + return AddAlias( + ExpressionProcessor.FindMemberExpression(path.Body), + ExpressionProcessor.FindMemberExpression(alias.Body), + JoinType.InnerJoin); + } + + public IList<T> List() + { + return _criteria.List<T>(); + } + + public ICriteria<T> GetExecutableQueryOver(ISession session) + { + _impl.Session = session.GetSessionImplementation(); + return this; + } + + private QueryOver<T> AddAlias(string path, string alias, JoinType joinType) + { + _criteria.CreateAlias(path, alias, joinType); + return this; + } + + private QueryOver<T> Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); + return this; + } + + private QueryOver<T> Add(Expression<Func<bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); + return this; + } + + } + +} Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -80,6 +80,11 @@ /// <returns>The list filled with the results.</returns> IList<T> List(); + /// <summary> + /// Get an executable instance of <c>Criteria<T></c>, + /// to actually run the query.</summary> + ICriteria<T> GetExecutableQueryOver(ISession session); + } } Deleted: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -1,96 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using NHibernate.SqlCommand; - -namespace NHibernate.Impl -{ - - /// <summary> - /// Implementation of the <see cref="ICriteria<T>"/> interface - /// </summary> - [Serializable] - public class CriteriaImpl<T> : ICriteria<T> - { - - private ICriteria _criteria; - - public CriteriaImpl(ICriteria criteria) - { - _criteria = criteria; - } - - public ICriteria UnderlyingCriteria - { - get { return _criteria; } - } - - ICriteria<T> ICriteria<T>.And(Expression<Func<T, bool>> expression) - { - return Add(expression); - } - - ICriteria<T> ICriteria<T>.And(Expression<Func<bool>> expression) - { - return Add(expression); - } - - ICriteria<T> ICriteria<T>.Where(Expression<Func<T, bool>> expression) - { - return Add(expression); - } - - ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression) - { - return Add(expression); - } - - ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, U>> path) - { - return new CriteriaImpl<U>( - _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(path.Body))); - } - - ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) - { - return new CriteriaImpl<U>( - _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(path.Body))); - } - - ICriteria<T> ICriteria<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) - { - return AddAlias( - ExpressionProcessor.FindMemberExpression(path.Body), - ExpressionProcessor.FindMemberExpression(alias.Body), - JoinType.InnerJoin); - } - - IList<T> ICriteria<T>.List() - { - return _criteria.List<T>(); - } - - private CriteriaImpl<T> AddAlias(string path, string alias, JoinType joinType) - { - _criteria.CreateAlias(path, alias, joinType); - return this; - } - - private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression) - { - _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); - return this; - } - - private CriteriaImpl<T> Add(Expression<Func<bool>> expression) - { - _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); - return this; - } - - } - -} Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -8,6 +8,7 @@ using log4net; using NHibernate.AdoNet; using NHibernate.Collection; +using NHibernate.Criterion; using NHibernate.Engine; using NHibernate.Engine.Query; using NHibernate.Engine.Query.Sql; @@ -1875,7 +1876,8 @@ { using (new SessionIdLoggingContext(SessionId)) { - return new CriteriaImpl<T>(CreateCriteria(typeof(T))); + CheckAndUpdateSessionStatus(); + return new QueryOver<T>(new CriteriaImpl(typeof(T), this)); } } Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 20:17:23 UTC (rev 4558) @@ -479,7 +479,6 @@ <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> - <Compile Include="Criterion\DetachedCriteriaOfT.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> @@ -531,7 +530,7 @@ <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> <Compile Include="ICriteriaOfT.cs" /> - <Compile Include="Impl\CriteriaOfTImpl.cs" /> + <Compile Include="Criterion\QueryOver.cs" /> <Compile Include="Impl\ExpressionProcessor.cs" /> <Compile Include="Impl\SessionIdLoggingContext.cs" /> <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -85,7 +85,7 @@ public void Where_BehavesTheSameAs_And() { Person personAlias = null; - Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>) + QueryOver<Person> expected = (QueryOver<Person>) CreateTestQueryOver<Person>(() => personAlias) .And(() => personAlias.Name == "test name") .And(p => p.Name == "test name"); Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -1,48 +0,0 @@ -using System; -using System.Collections; - -using NUnit.Framework; - -using NHibernate.Criterion; -using NHibernate.Transform; -using NHibernate.Type; -using NHibernate.Util; - -namespace NHibernate.Test.Criteria.Lambda -{ - - [TestFixture] - public class DetachedCriteriaOfTFixture : LambdaFixtureBase - { - - [Test] - public void SimpleCriterion_NoAlias() - { - DetachedCriteria expected = - DetachedCriteria.For<Person>() - .Add(Restrictions.Eq("Name", "test name")); - - DetachedCriteria<Person> actual = - DetachedCriteria.QueryOver<Person>() - .Where(p => p.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void Where_BehavesTheSameAs_And() - { - DetachedCriteria<Person> expected = - DetachedCriteria.QueryOver<Person>() - .And(p => p.Name == "test name"); - - DetachedCriteria<Person> actual = - DetachedCriteria.QueryOver<Person>() - .Where(p => p.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - } - -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -68,7 +68,7 @@ } [Test] - public void DetachedCriteriaOfT_SimpleCriterion() + public void DetachedQuery_SimpleCriterion() { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) @@ -80,11 +80,11 @@ using (ISession s = OpenSession()) { var personQuery = - DetachedCriteria.QueryOver<Person>() + new QueryOver<Person>() .Where(p => p.Name == "test person 1"); IList<Person> actual = - personQuery.GetExecutableCriteria(s) + personQuery.GetExecutableQueryOver(s) .List(); Assert.That(actual[0].Age, Is.EqualTo(20)); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-07-01 20:17:23 UTC (rev 4558) @@ -32,13 +32,13 @@ protected ICriteria<T> CreateTestQueryOver<T>() { - return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), null)); + return new QueryOver<T>(new CriteriaImpl(typeof(T), null)); } protected ICriteria<T> CreateTestQueryOver<T>(Expression<Func<object>> alias) { string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); - return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), aliasContainer, null)); + return new QueryOver<T>(new CriteriaImpl(typeof(T), aliasContainer, null)); } protected void AssertCriteriaAreEqual(ICriteria expected, ICriteria actual) @@ -53,7 +53,7 @@ protected void AssertCriteriaAreEqual<T>(ICriteria expected, ICriteria<T> actual) { - AssertObjectsAreEqual(expected, ((CriteriaImpl<T>)actual).UnderlyingCriteria); + AssertObjectsAreEqual(expected, ((QueryOver<T>)actual).UnderlyingCriteria); } private void AssertDictionariesAreEqual(IDictionary expected, IDictionary actual) Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-01 18:48:00 UTC (rev 4557) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-01 20:17:23 UTC (rev 4558) @@ -146,7 +146,6 @@ <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> - <Compile Include="Criteria\Lambda\DetachedCriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-02 04:24:54
|
Revision: 4560 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4560&view=rev Author: fabiomaulo Date: 2009-07-02 04:24:50 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Configuration through lambdas Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Hbm2ddlKeyWords.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/CacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/MappingsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ProxyConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/SchemaAutoAction.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/SchemaAutoActionFixture.cs Added: trunk/nhibernate/src/NHibernate/Cfg/Hbm2ddlKeyWords.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Hbm2ddlKeyWords.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Hbm2ddlKeyWords.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,85 @@ +namespace NHibernate.Cfg +{ + public class Hbm2DDLKeyWords + { + private readonly string value; + + private Hbm2DDLKeyWords(string value) + { + this.value = value; + } + + public override string ToString() + { + return value; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof(Hbm2DDLKeyWords)) + { + return false; + } + return Equals((Hbm2DDLKeyWords)obj); + } + + public bool Equals(string other) + { + return value.Equals(other); + } + + public bool Equals(Hbm2DDLKeyWords other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.value, value); + } + + public override int GetHashCode() + { + return (value != null ? value.GetHashCode() : 0); + } + + public static bool operator ==(string a, Hbm2DDLKeyWords b) + { + if (ReferenceEquals(null, b)) + { + return false; + } + return b.Equals(a); + } + + public static bool operator ==(Hbm2DDLKeyWords a, string b) + { + return b == a; + } + + public static bool operator !=(Hbm2DDLKeyWords a, string b) + { + return !(a == b); + } + + public static bool operator !=(string a, Hbm2DDLKeyWords b) + { + return !(a == b); + } + + public static Hbm2DDLKeyWords None = new Hbm2DDLKeyWords("none"); + public static Hbm2DDLKeyWords Keywords = new Hbm2DDLKeyWords("keywords"); + public static Hbm2DDLKeyWords AutoQuote = new Hbm2DDLKeyWords("auto-quote"); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/CacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/CacheConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/CacheConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,109 @@ +using NHibernate.Cache; + +namespace NHibernate.Cfg.Loquacious +{ + internal class CacheConfigurationProperties : ICacheConfigurationProperties + { + private readonly Configuration cfg; + + public CacheConfigurationProperties(Configuration cfg) + { + this.cfg = cfg; + } + + #region Implementation of ICacheConfigurationProperties + + public bool UseMinimalPuts + { + set { cfg.SetProperty(Environment.UseMinimalPuts, value.ToString().ToLowerInvariant()); } + } + + public string RegionsPrefix + { + set { cfg.SetProperty(Environment.CacheRegionPrefix, value); } + } + + public byte DefaultExpiration + { + set { cfg.SetProperty(Environment.CacheDefaultExpiration, value.ToString()); } + } + + public void Provider<TProvider>() where TProvider : ICacheProvider + { + cfg.SetProperty(Environment.CacheProvider, typeof (TProvider).AssemblyQualifiedName); + } + + public void QueryCache<TFactory>() where TFactory : IQueryCache + { + cfg.SetProperty(Environment.QueryCacheFactory, typeof (TFactory).AssemblyQualifiedName); + } + + #endregion + } + + internal class CacheConfiguration : ICacheConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public CacheConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + Queries = new QueryCacheConfiguration(this); + } + + internal Configuration Configuration + { + get { return fc.Configuration; } + } + + #region Implementation of ICacheConfiguration + + public ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider + { + fc.Configuration.SetProperty(Environment.CacheProvider, typeof(TProvider).AssemblyQualifiedName); + return this; + } + + public ICacheConfiguration PrefixingRegionsWith(string regionPrefix) + { + fc.Configuration.SetProperty(Environment.CacheRegionPrefix, regionPrefix); + return this; + } + + public ICacheConfiguration UsingMinimalPuts() + { + fc.Configuration.SetProperty(Environment.UseMinimalPuts, true.ToString().ToLowerInvariant()); + return this; + } + + public IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds) + { + fc.Configuration.SetProperty(Environment.CacheDefaultExpiration, seconds.ToString()); + return fc; + } + + public IQueryCacheConfiguration Queries { get; private set; } + + #endregion + } + + internal class QueryCacheConfiguration : IQueryCacheConfiguration + { + private readonly CacheConfiguration cc; + + public QueryCacheConfiguration(CacheConfiguration cc) + { + this.cc = cc; + } + + #region Implementation of IQueryCacheConfiguration + + public ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache + { + cc.Configuration.SetProperty(Environment.QueryCacheFactory, typeof(TFactory).AssemblyQualifiedName); + return cc; + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -1,3 +1,5 @@ +using System; +using NHibernate.Hql; namespace NHibernate.Cfg.Loquacious { public static class ConfigurationExtensions @@ -6,5 +8,48 @@ { return new FluentSessionFactoryConfiguration(configuration); } + + public static Configuration SessionFactoryName(this Configuration configuration, string sessionFactoryName) + { + configuration.SetProperty(Environment.SessionFactoryName, sessionFactoryName); + return configuration; + } + + public static Configuration Cache(this Configuration configuration, Action<ICacheConfigurationProperties> cacheProperties) + { + cacheProperties(new CacheConfigurationProperties(configuration)); + return configuration; + } + + public static Configuration CollectionTypeFactory<TCollecionsFactory>(this Configuration configuration) + { + configuration.SetProperty(Environment.CollectionTypeFactoryClass, + typeof(TCollecionsFactory).AssemblyQualifiedName); + return configuration; + } + + public static Configuration Proxy(this Configuration configuration, Action<IProxyConfigurationProperties> proxyProperties) + { + proxyProperties(new ProxyConfigurationProperties(configuration)); + return configuration; + } + + public static Configuration HqlQueryTranslator<TQueryTranslator>(this Configuration configuration) where TQueryTranslator : IQueryTranslatorFactory + { + configuration.SetProperty(Environment.QueryTranslator, typeof(TQueryTranslator).AssemblyQualifiedName); + return configuration; + } + + public static Configuration Mappings(this Configuration configuration, Action<IMappingsConfigurationProperties> mappingsProperties) + { + mappingsProperties(new MappingsConfigurationProperties(configuration)); + return configuration; + } + + public static Configuration DataBaseIntegration(this Configuration configuration, Action<IDbIntegrationConfigurationProperties> dataBaseIntegration) + { + dataBaseIntegration(new DbIntegrationConfigurationProperties(configuration)); + return configuration; + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,382 @@ +using System.Data; +using System.Data.Common; +using NHibernate.Connection; +using NHibernate.Driver; +using NHibernate.AdoNet; +using NHibernate.Exceptions; +using NHibernate.Transaction; + +namespace NHibernate.Cfg.Loquacious +{ + internal class DbIntegrationConfiguration : IDbIntegrationConfiguration + { + private readonly Configuration configuration; + + public DbIntegrationConfiguration(Configuration configuration) + { + this.configuration = configuration; + Connected = new ConnectionConfiguration(this); + BatchingQueries = new BatcherConfiguration(this); + Transactions = new TransactionConfiguration(this); + CreateCommands = new CommandsConfiguration(this); + Schema = new DbSchemaIntegrationConfiguration(this); + } + + public Configuration Configuration + { + get { return configuration; } + } + + #region Implementation of IDbIntegrationConfiguration + + public IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect + { + configuration.SetProperty(Environment.Dialect, typeof(TDialect).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration DisableKeywordsAutoImport() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "none"); + return this; + } + + public IDbIntegrationConfiguration AutoQuoteKeywords() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + return this; + } + + public IDbIntegrationConfiguration LogSqlInConsole() + { + configuration.SetProperty(Environment.ShowSql, "true"); + return this; + } + + public IDbIntegrationConfiguration DisableLogFormatedSql() + { + configuration.SetProperty(Environment.FormatSql, "false"); + return this; + } + + public IConnectionConfiguration Connected { get; private set; } + public IBatcherConfiguration BatchingQueries { get; private set; } + public ITransactionConfiguration Transactions { get; private set; } + + public ICommandsConfiguration CreateCommands { get; private set; } + + public IDbSchemaIntegrationConfiguration Schema { get; private set; } + + #endregion + } + + internal class DbSchemaIntegrationConfiguration : IDbSchemaIntegrationConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public DbSchemaIntegrationConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IDbSchemaIntegrationConfiguration + + public IDbIntegrationConfiguration Recreating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, SchemaAutoAction.Recreate.ToString()); + return dbc; + } + + public IDbIntegrationConfiguration Creating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, SchemaAutoAction.Create.ToString()); + return dbc; + } + + public IDbIntegrationConfiguration Updating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, SchemaAutoAction.Update.ToString()); + return dbc; + } + + public IDbIntegrationConfiguration Validating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, SchemaAutoAction.Validate.ToString()); + return dbc; + } + + #endregion + } + + internal class CommandsConfiguration : ICommandsConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public CommandsConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ICommandsConfiguration + + public ICommandsConfiguration Preparing() + { + dbc.Configuration.SetProperty(Environment.PrepareSql, "true"); + return this; + } + + public ICommandsConfiguration WithTimeout(byte seconds) + { + dbc.Configuration.SetProperty(Environment.CommandTimeout, seconds.ToString()); + return this; + } + + public ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() + where TExceptionConverter : ISQLExceptionConverter + { + dbc.Configuration.SetProperty(Environment.SqlExceptionConverter, typeof(TExceptionConverter).AssemblyQualifiedName); + return this; + } + + public ICommandsConfiguration AutoCommentingSql() + { + dbc.Configuration.SetProperty(Environment.UseSqlComments, "true"); + return this; + } + + public IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions) + { + dbc.Configuration.SetProperty(Environment.QuerySubstitutions, csvQuerySubstitutions); + return dbc; + } + + public IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions() + { + return dbc; + } + + public ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth) + { + dbc.Configuration.SetProperty(Environment.MaxFetchDepth, maxFetchDepth.ToString()); + return this; + } + + #endregion + } + + internal class TransactionConfiguration : ITransactionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public TransactionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ITransactionConfiguration + + public IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory + { + dbc.Configuration.SetProperty(Environment.TransactionStrategy, typeof(TFactory).AssemblyQualifiedName); + return dbc; + } + + #endregion + } + + internal class BatcherConfiguration : IBatcherConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public BatcherConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IBatcherConfiguration + + public IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory + { + dbc.Configuration.SetProperty(Environment.BatchStrategy, typeof(TBatcher).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration Each(short batchSize) + { + dbc.Configuration.SetProperty(Environment.BatchSize, batchSize.ToString()); + return dbc; + } + + #endregion + } + + internal class ConnectionConfiguration : IConnectionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public ConnectionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IConnectionConfiguration + + public IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider + { + dbc.Configuration.SetProperty(Environment.ConnectionProvider, typeof(TProvider).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration By<TDriver>() where TDriver : IDriver + { + dbc.Configuration.SetProperty(Environment.ConnectionDriver, typeof(TDriver).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration With(IsolationLevel level) + { + dbc.Configuration.SetProperty(Environment.Isolation, level.ToString()); + return this; + } + + public IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode) + { + dbc.Configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(releaseMode)); + return this; + } + + public IDbIntegrationConfiguration Using(string connectionString) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionString); + return dbc; + } + + public IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionStringBuilder.ConnectionString); + return dbc; + } + + public IDbIntegrationConfiguration ByAppConfing(string connectionStringName) + { + dbc.Configuration.SetProperty(Environment.ConnectionStringName, connectionStringName); + return dbc; + } + + #endregion + } + + internal class DbIntegrationConfigurationProperties: IDbIntegrationConfigurationProperties + { + private readonly Configuration configuration; + + public DbIntegrationConfigurationProperties(Configuration configuration) + { + this.configuration = configuration; + } + + #region Implementation of IDbIntegrationConfigurationProperties + + public void Dialect<TDialect>() where TDialect : Dialect.Dialect + { + configuration.SetProperty(Environment.Dialect, typeof(TDialect).AssemblyQualifiedName); + } + + public Hbm2DDLKeyWords KeywordsAutoImport + { + set { configuration.SetProperty(Environment.Hbm2ddlKeyWords, value.ToString()); } + } + + public bool LogSqlInConsole + { + set { configuration.SetProperty(Environment.ShowSql, value.ToString().ToLowerInvariant()); } + } + + public bool LogFormatedSql + { + set { configuration.SetProperty(Environment.FormatSql, value.ToString().ToLowerInvariant()); } + } + + public void ConnectionProvider<TProvider>() where TProvider : IConnectionProvider + { + configuration.SetProperty(Environment.ConnectionProvider, typeof(TProvider).AssemblyQualifiedName); + } + + public void Driver<TDriver>() where TDriver : IDriver + { + configuration.SetProperty(Environment.ConnectionDriver, typeof(TDriver).AssemblyQualifiedName); + } + + public IsolationLevel IsolationLevel + { + set { configuration.SetProperty(Environment.Isolation, value.ToString()); } + } + + public ConnectionReleaseMode ConnectionReleaseMode + { + set { configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(value)); } + } + + public string ConnectionString + { + set { configuration.SetProperty(Environment.ConnectionString, value); } + } + + public string ConnectionStringName + { + set { configuration.SetProperty(Environment.ConnectionStringName, value); } + } + + public void Batcher<TBatcher>() where TBatcher : IBatcherFactory + { + configuration.SetProperty(Environment.BatchStrategy, typeof(TBatcher).AssemblyQualifiedName); + } + + public short BatchSize + { + set { configuration.SetProperty(Environment.BatchSize, value.ToString()); } + } + + public void TransactionFactory<TFactory>() where TFactory : ITransactionFactory + { + configuration.SetProperty(Environment.TransactionStrategy, typeof(TFactory).AssemblyQualifiedName); + } + + public bool PrepareCommands + { + set { configuration.SetProperty(Environment.PrepareSql, value.ToString().ToLowerInvariant()); } + } + + public byte Timeout + { + set { configuration.SetProperty(Environment.CommandTimeout, value.ToString()); } + } + + public void ExceptionConverter<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter + { + configuration.SetProperty(Environment.SqlExceptionConverter, typeof(TExceptionConverter).AssemblyQualifiedName); + } + + public bool AutoCommentSql + { + set { configuration.SetProperty(Environment.UseSqlComments, value.ToString().ToLowerInvariant()); } + } + + public string HqlToSqlSubstitutions + { + set { configuration.SetProperty(Environment.QuerySubstitutions, value); } + } + + public byte MaximumDepthOfOuterJoinFetching + { + set { configuration.SetProperty(Environment.MaxFetchDepth, value.ToString()); } + } + + public SchemaAutoAction SchemaAction + { + set { configuration.SetProperty(Environment.Hbm2ddlAuto, value.ToString()); } + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -1,13 +1,5 @@ -using System.Data; -using System.Data.Common; -using NHibernate.AdoNet; using NHibernate.Bytecode; -using NHibernate.Cache; -using NHibernate.Connection; -using NHibernate.Driver; -using NHibernate.Exceptions; using NHibernate.Hql; -using NHibernate.Transaction; namespace NHibernate.Cfg.Loquacious { @@ -68,358 +60,6 @@ #endregion } - internal class DbIntegrationConfiguration : IDbIntegrationConfiguration - { - private readonly Configuration configuration; - - public DbIntegrationConfiguration(Configuration configuration) - { - this.configuration = configuration; - Connected = new ConnectionConfiguration(this); - BatchingQueries = new BatcherConfiguration(this); - Transactions = new TransactionConfiguration(this); - CreateCommands = new CommandsConfiguration(this); - Schema = new DbSchemaIntegrationConfiguration(this); - } - - public Configuration Configuration - { - get { return configuration; } - } - - #region Implementation of IDbIntegrationConfiguration - - public IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect - { - configuration.SetProperty(Environment.Dialect, typeof (TDialect).AssemblyQualifiedName); - return this; - } - - public IDbIntegrationConfiguration DisableKeywordsAutoImport() - { - configuration.SetProperty(Environment.Hbm2ddlKeyWords, "none"); - return this; - } - - public IDbIntegrationConfiguration AutoQuoteKeywords() - { - configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); - return this; - } - - public IDbIntegrationConfiguration LogSqlInConsole() - { - configuration.SetProperty(Environment.ShowSql, "true"); - return this; - } - - public IDbIntegrationConfiguration DisableLogFormatedSql() - { - configuration.SetProperty(Environment.FormatSql, "false"); - return this; - } - - public IConnectionConfiguration Connected { get; private set; } - public IBatcherConfiguration BatchingQueries { get; private set; } - public ITransactionConfiguration Transactions { get; private set; } - - public ICommandsConfiguration CreateCommands { get; private set; } - - public IDbSchemaIntegrationConfiguration Schema { get; private set; } - - #endregion - } - - internal class DbSchemaIntegrationConfiguration : IDbSchemaIntegrationConfiguration - { - private readonly DbIntegrationConfiguration dbc; - - public DbSchemaIntegrationConfiguration(DbIntegrationConfiguration dbc) - { - this.dbc = dbc; - } - - #region Implementation of IDbSchemaIntegrationConfiguration - - public IDbIntegrationConfiguration Recreating() - { - dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create-drop"); - return dbc; - } - - public IDbIntegrationConfiguration Creating() - { - dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create"); - return dbc; - } - - public IDbIntegrationConfiguration Updating() - { - dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "update"); - return dbc; - } - - public IDbIntegrationConfiguration Validating() - { - dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "validate"); - return dbc; - } - - #endregion - } - - internal class CommandsConfiguration : ICommandsConfiguration - { - private readonly DbIntegrationConfiguration dbc; - - public CommandsConfiguration(DbIntegrationConfiguration dbc) - { - this.dbc = dbc; - } - - #region Implementation of ICommandsConfiguration - - public ICommandsConfiguration Preparing() - { - dbc.Configuration.SetProperty(Environment.PrepareSql, "true"); - return this; - } - - public ICommandsConfiguration WithTimeout(int seconds) - { - dbc.Configuration.SetProperty(Environment.CommandTimeout, seconds.ToString()); - return this; - } - - public ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() - where TExceptionConverter : ISQLExceptionConverter - { - dbc.Configuration.SetProperty(Environment.SqlExceptionConverter, typeof (TExceptionConverter).AssemblyQualifiedName); - return this; - } - - public ICommandsConfiguration AutoCommentingSql() - { - dbc.Configuration.SetProperty(Environment.UseSqlComments, "true"); - return this; - } - - public IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions) - { - dbc.Configuration.SetProperty(Environment.QuerySubstitutions, csvQuerySubstitutions); - return dbc; - } - - public IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions() - { - return dbc; - } - - public ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth) - { - dbc.Configuration.SetProperty(Environment.MaxFetchDepth, maxFetchDepth.ToString()); - return this; - } - - #endregion - } - - internal class TransactionConfiguration : ITransactionConfiguration - { - private readonly DbIntegrationConfiguration dbc; - - public TransactionConfiguration(DbIntegrationConfiguration dbc) - { - this.dbc = dbc; - } - - #region Implementation of ITransactionConfiguration - - public IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory - { - dbc.Configuration.SetProperty(Environment.TransactionStrategy, typeof (TFactory).AssemblyQualifiedName); - return dbc; - } - - #endregion - } - - internal class BatcherConfiguration : IBatcherConfiguration - { - private readonly DbIntegrationConfiguration dbc; - - public BatcherConfiguration(DbIntegrationConfiguration dbc) - { - this.dbc = dbc; - } - - #region Implementation of IBatcherConfiguration - - public IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory - { - dbc.Configuration.SetProperty(Environment.BatchStrategy, typeof (TBatcher).AssemblyQualifiedName); - return this; - } - - public IDbIntegrationConfiguration Each(short batchSize) - { - dbc.Configuration.SetProperty(Environment.BatchSize, batchSize.ToString()); - return dbc; - } - - #endregion - } - - internal class ConnectionConfiguration : IConnectionConfiguration - { - private readonly DbIntegrationConfiguration dbc; - - public ConnectionConfiguration(DbIntegrationConfiguration dbc) - { - this.dbc = dbc; - } - - #region Implementation of IConnectionConfiguration - - public IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider - { - dbc.Configuration.SetProperty(Environment.ConnectionProvider, typeof (TProvider).AssemblyQualifiedName); - return this; - } - - public IConnectionConfiguration By<TDriver>() where TDriver : IDriver - { - dbc.Configuration.SetProperty(Environment.ConnectionDriver, typeof (TDriver).AssemblyQualifiedName); - return this; - } - - public IConnectionConfiguration With(IsolationLevel level) - { - dbc.Configuration.SetProperty(Environment.Isolation, level.ToString()); - return this; - } - - public IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode) - { - dbc.Configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(releaseMode)); - return this; - } - - public IDbIntegrationConfiguration Using(string connectionString) - { - dbc.Configuration.SetProperty(Environment.ConnectionString, connectionString); - return dbc; - } - - public IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder) - { - dbc.Configuration.SetProperty(Environment.ConnectionString, connectionStringBuilder.ConnectionString); - return dbc; - } - - public IDbIntegrationConfiguration ByAppConfing(string connectionStringName) - { - dbc.Configuration.SetProperty(Environment.ConnectionStringName, connectionStringName); - return dbc; - } - - #endregion - } - - internal class CacheConfiguration : ICacheConfiguration - { - private readonly FluentSessionFactoryConfiguration fc; - - public CacheConfiguration(FluentSessionFactoryConfiguration parent) - { - fc = parent; - Queries = new QueryCacheConfiguration(this); - } - - internal Configuration Configuration - { - get { return fc.Configuration; } - } - - #region Implementation of ICacheConfiguration - - public ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider - { - fc.Configuration.SetProperty(Environment.CacheProvider, typeof (TProvider).AssemblyQualifiedName); - return this; - } - - public ICacheConfiguration PrefixingRegionsWith(string regionPrefix) - { - fc.Configuration.SetProperty(Environment.CacheRegionPrefix, regionPrefix); - return this; - } - - public ICacheConfiguration UsingMinimalPuts() - { - fc.Configuration.SetProperty(Environment.UseMinimalPuts, "true"); - return this; - } - - public IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds) - { - fc.Configuration.SetProperty(Environment.CacheDefaultExpiration, seconds.ToString()); - return fc; - } - - public IQueryCacheConfiguration Queries { get; private set; } - - #endregion - } - - internal class QueryCacheConfiguration : IQueryCacheConfiguration - { - private readonly CacheConfiguration cc; - - public QueryCacheConfiguration(CacheConfiguration cc) - { - this.cc = cc; - } - - #region Implementation of IQueryCacheConfiguration - - public ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache - { - cc.Configuration.SetProperty(Environment.QueryCacheFactory, typeof (TFactory).AssemblyQualifiedName); - return cc; - } - - #endregion - } - - internal class ProxyConfiguration : IProxyConfiguration - { - private readonly FluentSessionFactoryConfiguration fc; - - public ProxyConfiguration(FluentSessionFactoryConfiguration parent) - { - fc = parent; - } - - #region Implementation of IProxyConfiguration - - public IProxyConfiguration DisableValidation() - { - fc.Configuration.SetProperty(Environment.UseProxyValidator, "false"); - return this; - } - - public IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() - where TProxyFactoryFactory : IProxyFactoryFactory - { - fc.Configuration.SetProperty(Environment.ProxyFactoryFactoryClass, - typeof (TProxyFactoryFactory).AssemblyQualifiedName); - return fc; - } - - #endregion - } - internal class CollectionFactoryConfiguration : ICollectionFactoryConfiguration { private readonly FluentSessionFactoryConfiguration fc; @@ -441,30 +81,4 @@ #endregion } - - internal class MappingsConfiguration : IMappingsConfiguration - { - private readonly FluentSessionFactoryConfiguration fc; - - public MappingsConfiguration(FluentSessionFactoryConfiguration parent) - { - fc = parent; - } - - #region Implementation of IMappingsConfiguration - - public IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName) - { - fc.Configuration.SetProperty(Environment.DefaultCatalog, defaultCatalogName); - return this; - } - - public IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName) - { - fc.Configuration.SetProperty(Environment.DefaultSchema, defaultSchemaName); - return fc; - } - - #endregion - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -9,4 +9,13 @@ IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds); IQueryCacheConfiguration Queries { get; } } + + public interface ICacheConfigurationProperties + { + bool UseMinimalPuts { set; } + string RegionsPrefix { set; } + byte DefaultExpiration { set; } + void Provider<TProvider>() where TProvider : ICacheProvider; + void QueryCache<TFactory>() where TFactory : IQueryCache; + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -4,7 +4,7 @@ public interface ICommandsConfiguration { ICommandsConfiguration Preparing(); - ICommandsConfiguration WithTimeout(int seconds); + ICommandsConfiguration WithTimeout(byte seconds); ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; ICommandsConfiguration AutoCommentingSql(); IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -1,3 +1,10 @@ +using System.Data; +using NHibernate.AdoNet; +using NHibernate.Driver; +using NHibernate.Connection; +using NHibernate.Transaction; +using NHibernate.Exceptions; + namespace NHibernate.Cfg.Loquacious { public interface IDbIntegrationConfiguration @@ -22,6 +29,34 @@ ICommandsConfiguration CreateCommands { get; } IDbSchemaIntegrationConfiguration Schema { get; } + } + public interface IDbIntegrationConfigurationProperties + { + void Dialect<TDialect>() where TDialect : Dialect.Dialect; + Hbm2DDLKeyWords KeywordsAutoImport { set; } + bool LogSqlInConsole { set; } + bool LogFormatedSql { set; } + + void ConnectionProvider<TProvider>() where TProvider : IConnectionProvider; + void Driver<TDriver>() where TDriver : IDriver; + IsolationLevel IsolationLevel { set; } + ConnectionReleaseMode ConnectionReleaseMode { set; } + string ConnectionString { set; } + string ConnectionStringName { set; } + + void Batcher<TBatcher>() where TBatcher : IBatcherFactory; + short BatchSize { set; } + + void TransactionFactory<TFactory>() where TFactory : ITransactionFactory; + + bool PrepareCommands { set; } + byte Timeout { set; } + void ExceptionConverter<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; + bool AutoCommentSql { set; } + string HqlToSqlSubstitutions { set; } + byte MaximumDepthOfOuterJoinFetching { set; } + + SchemaAutoAction SchemaAction { set; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -5,4 +5,10 @@ IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName); IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName); } + + public interface IMappingsConfigurationProperties + { + string DefaultCatalog { set; } + string DefaultSchema { set; } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -6,4 +6,10 @@ IProxyConfiguration DisableValidation(); IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; } + + public interface IProxyConfigurationProperties + { + bool Validation { set; } + void ProxyFactoryFactory<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; + } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/MappingsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/MappingsConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/MappingsConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,54 @@ +using System; + +namespace NHibernate.Cfg.Loquacious +{ + internal class MappingsConfiguration : IMappingsConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public MappingsConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IMappingsConfiguration + + public IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName) + { + fc.Configuration.SetProperty(Environment.DefaultCatalog, defaultCatalogName); + return this; + } + + public IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName) + { + fc.Configuration.SetProperty(Environment.DefaultSchema, defaultSchemaName); + return fc; + } + + #endregion + } + + internal class MappingsConfigurationProperties:IMappingsConfigurationProperties + { + private readonly Configuration configuration; + + public MappingsConfigurationProperties(Configuration configuration) + { + this.configuration = configuration; + } + + #region Implementation of IMappingsConfigurationProperties + + public string DefaultCatalog + { + set { configuration.SetProperty(Environment.DefaultCatalog, value); } + } + + public string DefaultSchema + { + set { configuration.SetProperty(Environment.DefaultSchema, value); } + } + + #endregion + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ProxyConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ProxyConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ProxyConfiguration.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,57 @@ +using NHibernate.Bytecode; + +namespace NHibernate.Cfg.Loquacious +{ + internal class ProxyConfiguration : IProxyConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public ProxyConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IProxyConfiguration + + public IProxyConfiguration DisableValidation() + { + fc.Configuration.SetProperty(Environment.UseProxyValidator, "false"); + return this; + } + + public IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() + where TProxyFactoryFactory : IProxyFactoryFactory + { + fc.Configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(TProxyFactoryFactory).AssemblyQualifiedName); + return fc; + } + + #endregion + } + + internal class ProxyConfigurationProperties: IProxyConfigurationProperties + { + private readonly Configuration configuration; + + public ProxyConfigurationProperties(Configuration configuration) + { + this.configuration = configuration; + } + + #region Implementation of IProxyConfigurationProperties + + public bool Validation + { + set { configuration.SetProperty(Environment.UseProxyValidator, value.ToString().ToLowerInvariant()); } + } + + public void ProxyFactoryFactory<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(TProxyFactoryFactory).AssemblyQualifiedName); + } + + #endregion + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/SchemaAutoAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SchemaAutoAction.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/SchemaAutoAction.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,86 @@ +namespace NHibernate.Cfg +{ + public class SchemaAutoAction + { + private readonly string value; + + private SchemaAutoAction(string value) + { + this.value = value; + } + + public override string ToString() + { + return value; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof(SchemaAutoAction)) + { + return false; + } + return Equals((SchemaAutoAction)obj); + } + + public bool Equals(string other) + { + return value.Equals(other); + } + + public bool Equals(SchemaAutoAction other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.value, value); + } + + public override int GetHashCode() + { + return (value != null ? value.GetHashCode() : 0); + } + + public static bool operator ==(string a, SchemaAutoAction b) + { + if (ReferenceEquals(null, b)) + { + return false; + } + return b.Equals(a); + } + + public static bool operator ==(SchemaAutoAction a, string b) + { + return b == a; + } + + public static bool operator !=(SchemaAutoAction a, string b) + { + return !(a == b); + } + + public static bool operator !=(string a, SchemaAutoAction b) + { + return !(a == b); + } + + public static SchemaAutoAction Recreate = new SchemaAutoAction("create-drop"); + public static SchemaAutoAction Create = new SchemaAutoAction("create"); + public static SchemaAutoAction Update = new SchemaAutoAction("update"); + public static SchemaAutoAction Validate = new SchemaAutoAction("validate"); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -142,43 +142,45 @@ #region Hbm2DDL string autoSchemaExport = PropertiesHelper.GetString(Environment.Hbm2ddlAuto, properties, null); - if ("update" == autoSchemaExport) + if (SchemaAutoAction.Update == autoSchemaExport) { settings.IsAutoUpdateSchema = true; } - if ("create" == autoSchemaExport) + else if (SchemaAutoAction.Create == autoSchemaExport) { settings.IsAutoCreateSchema = true; } - if ("create-drop" == autoSchemaExport) + else if (SchemaAutoAction.Recreate == autoSchemaExport) { settings.IsAutoCreateSchema = true; settings.IsAutoDropSchema = true; } - if ("validate" == autoSchemaExport) + else if (SchemaAutoAction.Validate == autoSchemaExport) { settings.IsAutoValidateSchema = true; } string autoKeyWordsImport = PropertiesHelper.GetString(Environment.Hbm2ddlKeyWords, properties, "not-defined"); - switch (autoKeyWordsImport.ToLowerInvariant()) + autoKeyWordsImport = autoKeyWordsImport.ToLowerInvariant(); + if (autoKeyWordsImport == Hbm2DDLKeyWords.None) { - case "none": - settings.IsKeywordsImportEnabled = false; - settings.IsAutoQuoteEnabled = false; - break; - case "keywords": - settings.IsKeywordsImportEnabled = true; - break; - case "auto-quote": - settings.IsKeywordsImportEnabled = true; - settings.IsAutoQuoteEnabled = true; - break; - case "not-defined": - settings.IsKeywordsImportEnabled = true; - settings.IsAutoQuoteEnabled = false; - break; + settings.IsKeywordsImportEnabled = false; + settings.IsAutoQuoteEnabled = false; } + else if (autoKeyWordsImport == Hbm2DDLKeyWords.Keywords) + { + settings.IsKeywordsImportEnabled = true; + } + else if (autoKeyWordsImport == Hbm2DDLKeyWords.AutoQuote) + { + settings.IsKeywordsImportEnabled = true; + settings.IsAutoQuoteEnabled = true; + } + else if (autoKeyWordsImport == "not-defined") + { + settings.IsKeywordsImportEnabled = true; + settings.IsAutoQuoteEnabled = false; + } #endregion Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-02 04:24:50 UTC (rev 4560) @@ -459,7 +459,10 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\Hbm2ddlKeyWords.cs" /> + <Compile Include="Cfg\Loquacious\CacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> + <Compile Include="Cfg\Loquacious\DbIntegrationConfiguration.cs" /> <Compile Include="Cfg\Loquacious\FluentSessionFactoryConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> @@ -473,6 +476,9 @@ <Compile Include="Cfg\Loquacious\IProxyConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IQueryCacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ITransactionConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\MappingsConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ProxyConfiguration.cs" /> + <Compile Include="Cfg\SchemaAutoAction.cs" /> <Compile Include="Cfg\SessionFactoryConfigurationBase.cs" /> <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,104 @@ +using NHibernate.AdoNet; +using NHibernate.Cache; +using NHibernate.Cfg; +using NHibernate.Dialect; +using NHibernate.Driver; +using NHibernate.Hql.Classic; +using NHibernate.Type; +using NUnit.Framework; +using NHibernate.Cfg.Loquacious; +using System.Data; +using NHibernate.Exceptions; + +namespace NHibernate.Test.CfgTest.Loquacious +{ + [TestFixture] + public class LambdaConfigurationFixture + { + [Test] + public void FullConfiguration() + { + var configure = new Configuration(); + configure.SessionFactoryName("SomeName"); + configure.Cache(c => + { + c.UseMinimalPuts = true; + c.DefaultExpiration = 15; + c.RegionsPrefix = "xyz"; + c.Provider<HashtableCacheProvider>(); + c.QueryCache<StandardQueryCache>(); + }); + configure.CollectionTypeFactory<DefaultCollectionTypeFactory>(); + configure.HqlQueryTranslator<ClassicQueryTranslatorFactory>(); + configure.Proxy(p => + { + p.Validation = false; + p.ProxyFactoryFactory<ByteCode.LinFu.ProxyFactoryFactory>(); + }); + configure.Mappings(m=> + { + m.DefaultCatalog = "MyCatalog"; + m.DefaultSchema = "MySche"; + }); + configure.DataBaseIntegration(db => + { + db.Dialect<MsSql2000Dialect>(); + db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; + db.Batcher<SqlClientBatchingBatcherFactory>(); + db.BatchSize = 15; + db.ConnectionProvider<DebugConnectionProvider>(); + db.Driver<SqlClientDriver>(); + db.ConnectionReleaseMode = ConnectionReleaseMode.AfterTransaction; + db.IsolationLevel = IsolationLevel.ReadCommitted; + db.ConnectionString = "The connection string"; + db.AutoCommentSql = true; + db.ExceptionConverter<SQLStateConverter>(); + db.PrepareCommands = true; + db.Timeout = 10; + db.MaximumDepthOfOuterJoinFetching = 11; + db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'"; + db.SchemaAction = SchemaAutoAction.Validate; + }); + + Assert.That(configure.Properties[Environment.SessionFactoryName], Is.EqualTo("SomeName")); + Assert.That(configure.Properties[Environment.CacheProvider], + Is.EqualTo(typeof(HashtableCacheProvider).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.CacheRegionPrefix], Is.EqualTo("xyz")); + Assert.That(configure.Properties[Environment.QueryCacheFactory], + Is.EqualTo(typeof(StandardQueryCache).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.UseMinimalPuts], Is.EqualTo("true")); + Assert.That(configure.Properties[Environment.CacheDefaultExpiration], Is.EqualTo("15")); + Assert.That(configure.Properties[Environment.CollectionTypeFactoryClass], + Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.UseProxyValidator], Is.EqualTo("false")); + Assert.That(configure.Properties[Environment.ProxyFactoryFactoryClass], + Is.EqualTo(typeof(ByteCode.LinFu.ProxyFactoryFactory).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.QueryTranslator], + Is.EqualTo(typeof(ClassicQueryTranslatorFactory).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog")); + Assert.That(configure.Properties[Environment.DefaultSchema], Is.EqualTo("MySche")); + Assert.That(configure.Properties[Environment.Dialect], + Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote")); + Assert.That(configure.Properties[Environment.BatchStrategy], + Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.BatchSize], Is.EqualTo("15")); + Assert.That(configure.Properties[Environment.ConnectionProvider], + Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.ConnectionDriver], + Is.EqualTo(typeof(SqlClientDriver).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.ReleaseConnections], + Is.EqualTo(ConnectionReleaseModeParser.ToString(ConnectionReleaseMode.AfterTransaction))); + Assert.That(configure.Properties[Environment.Isolation], Is.EqualTo("ReadCommitted")); + Assert.That(configure.Properties[Environment.ConnectionString], Is.EqualTo("The connection string")); + Assert.That(configure.Properties[Environment.UseSqlComments], Is.EqualTo("true")); + Assert.That(configure.Properties[Environment.SqlExceptionConverter], + Is.EqualTo(typeof(SQLStateConverter).AssemblyQualifiedName)); + Assert.That(configure.Properties[Environment.PrepareSql], Is.EqualTo("true")); + Assert.That(configure.Properties[Environment.CommandTimeout], Is.EqualTo("10")); + Assert.That(configure.Properties[Environment.MaxFetchDepth], Is.EqualTo("11")); + Assert.That(configure.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'")); + Assert.That(configure.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate")); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/SchemaAutoActionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/SchemaAutoActionFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/SchemaAutoActionFixture.cs 2009-07-02 04:24:50 UTC (rev 4560) @@ -0,0 +1,22 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.CfgTest +{ + [TestFixture] + public class SchemaAutoActionFixture + { + [Test] + public void Equality() + { + Assert.That(SchemaAutoAction.Recreate.Equals("create-drop")); + Assert.That(SchemaAutoAction.Recreate == "create-drop"); + Assert.That(SchemaAutoAction.Create.Equals("create")); + Assert.That(SchemaAutoAction.Create == "create"); + Assert.That(SchemaAutoAction.Update.Equals("update")); + Assert.That(SchemaAutoAction.Update == "update"); + Assert.That(SchemaAutoAction.Validate.Equals("validate")); + Assert.That(SchemaAutoAction.Validate == "validate"); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-01 20:36:07 UTC (rev 4559) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-02 04:24:50 UTC (rev 4560) @@ -108,8 +108,10 @@ <Compile Include="CfgTest\HbmOrderingFixture.cs" /> <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> <Compile Include="CfgTest\Loquacious\ConfigurationFixture.cs" /> + <Compile Include="CfgTest\Loquacious\LambdaConfigurationFixture.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> + <Compile Include="CfgTest\SchemaAutoActionFixture.cs" /> <Compile Include="CfgTest\SettingsFactoryFixture.cs" /> <Compile Include="Classic\EntityWithLifecycle.cs" /> <Compile Include="Classic\LifecycleFixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-02 20:55:18
|
Revision: 4561 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4561&view=rev Author: ricbrown Date: 2009-07-02 20:55:15 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Renamed interface to match class. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/ISession.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -10,10 +10,10 @@ { /// <summary> - /// Implementation of the <see cref="ICriteria<T>"/> interface + /// Implementation of the <see cref="IQueryOver<T>"/> interface /// </summary> [Serializable] - public class QueryOver<T> : ICriteria<T> + public class QueryOver<T> : IQueryOver<T> { private ICriteria _criteria; @@ -42,41 +42,41 @@ get { return _criteria; } } - public ICriteria<T> And(Expression<Func<T, bool>> expression) + public IQueryOver<T> And(Expression<Func<T, bool>> expression) { return Add(expression); } - public ICriteria<T> And(Expression<Func<bool>> expression) + public IQueryOver<T> And(Expression<Func<bool>> expression) { return Add(expression); } - public ICriteria<T> Where(Expression<Func<T, bool>> expression) + public IQueryOver<T> Where(Expression<Func<T, bool>> expression) { return Add(expression); } - public ICriteria<T> Where(Expression<Func<bool>> expression) + public IQueryOver<T> Where(Expression<Func<bool>> expression) { return Add(expression); } - public ICriteria<U> JoinWalk<U>(Expression<Func<T, U>> path) + public IQueryOver<U> JoinWalk<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( ExpressionProcessor.FindMemberExpression(path.Body))); } - public ICriteria<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) + public IQueryOver<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( ExpressionProcessor.FindMemberExpression(path.Body))); } - public ICriteria<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + public IQueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) { return AddAlias( ExpressionProcessor.FindMemberExpression(path.Body), @@ -89,7 +89,7 @@ return _criteria.List<T>(); } - public ICriteria<T> GetExecutableQueryOver(ISession session) + public IQueryOver<T> GetExecutableQueryOver(ISession session) { _impl.Session = session.GetSessionImplementation(); return this; Deleted: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -1,90 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq.Expressions; - -namespace NHibernate -{ - - /// <summary> - /// Criteria<T> is an API for retrieving entities by composing - /// <see cref="Criterion.Expression" /> objects expressed using Lambda expression syntax. - /// </summary> - /// <remarks> - /// <code> - /// IList<Cat> cats = session.QueryOver<Cat>() - /// .Add( c => c.Name == "Tigger" ) - /// .Add( c => c.Weight > minWeight ) ) - /// .List(); - /// </code> - /// </remarks> - public interface ICriteria<T> - { - - /// <summary> - /// Add criterion expressed as a lambda expression - /// </summary> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria<T> And(Expression<Func<T, bool>> expression); - - /// <summary> - /// Add criterion expressed as a lambda expression - /// </summary> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria<T> And(Expression<Func<bool>> expression); - - /// <summary> - /// Identical semantics to Add() to allow more readable queries - /// </summary> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria<T> Where(Expression<Func<T, bool>> expression); - - /// <summary> - /// Identical semantics to Add() to allow more readable queries - /// </summary> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria<T> Where(Expression<Func<bool>> expression); - - /// <summary> - /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity - /// </summary> - /// <typeparam name="U">Type of sub-criteria</typeparam> - /// <param name="path">Lambda expression returning association path</param> - /// <returns>The created "sub criteria"</returns> - ICriteria<U> JoinWalk<U>(Expression<Func<T, U>> path); - - /// <summary> - /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity - /// specifying a collection for the join. - /// </summary> - /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> - /// <param name="path">Lambda expression returning association path</param> - /// <returns>The created "sub criteria"</returns> - ICriteria<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path); - - /// <summary> - /// Join an association, assigning an alias to the joined entity - /// </summary> - /// <param name="path">Lambda expression returning association path</param> - /// <param name="alias">Lambda expression returning alias reference</param> - /// <returns>criteria instance</returns> - ICriteria<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias); - - /// <summary> - /// Get the results of the root type and fill the <see cref="IList<T>"/> - /// </summary> - /// <returns>The list filled with the results.</returns> - IList<T> List(); - - /// <summary> - /// Get an executable instance of <c>Criteria<T></c>, - /// to actually run the query.</summary> - ICriteria<T> GetExecutableQueryOver(ISession session); - - } - -} Copied: trunk/nhibernate/src/NHibernate/IQueryOver.cs (from rev 4560, trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -0,0 +1,90 @@ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace NHibernate +{ + + /// <summary> + /// QueryOver<T> is an API for retrieving entities by composing + /// <see cref="Criterion.Expression" /> objects expressed using Lambda expression syntax. + /// </summary> + /// <remarks> + /// <code> + /// IList<Cat> cats = session.QueryOver<Cat>() + /// .Add( c => c.Name == "Tigger" ) + /// .Add( c => c.Weight > minWeight ) ) + /// .List(); + /// </code> + /// </remarks> + public interface IQueryOver<T> + { + + /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + IQueryOver<T> And(Expression<Func<T, bool>> expression); + + /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + IQueryOver<T> And(Expression<Func<bool>> expression); + + /// <summary> + /// Identical semantics to Add() to allow more readable queries + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + IQueryOver<T> Where(Expression<Func<T, bool>> expression); + + /// <summary> + /// Identical semantics to Add() to allow more readable queries + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + IQueryOver<T> Where(Expression<Func<bool>> expression); + + /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// </summary> + /// <typeparam name="U">Type of sub-criteria</typeparam> + /// <param name="path">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + IQueryOver<U> JoinWalk<U>(Expression<Func<T, U>> path); + + /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// specifying a collection for the join. + /// </summary> + /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> + /// <param name="path">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + IQueryOver<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path); + + /// <summary> + /// Join an association, assigning an alias to the joined entity + /// </summary> + /// <param name="path">Lambda expression returning association path</param> + /// <param name="alias">Lambda expression returning alias reference</param> + /// <returns>criteria instance</returns> + IQueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias); + + /// <summary> + /// Get the results of the root type and fill the <see cref="IList<T>"/> + /// </summary> + /// <returns>The list filled with the results.</returns> + IList<T> List(); + + /// <summary> + /// Get an executable instance of <c>Criteria<T></c>, + /// to actually run the query.</summary> + IQueryOver<T> GetExecutableQueryOver(ISession session); + + } + +} Modified: trunk/nhibernate/src/NHibernate/ISession.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ISession.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate/ISession.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -787,7 +787,7 @@ /// </summary> /// <typeparam name="T">The entity class</typeparam> /// <returns>An ICriteria<T> object</returns> - ICriteria<T> QueryOver<T>() where T : class; + IQueryOver<T> QueryOver<T>() where T : class; /// <summary> /// Create a new instance of <c>Query</c> for the given query string Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -1872,7 +1872,7 @@ } } - public ICriteria<T> QueryOver<T>() where T : class + public IQueryOver<T> QueryOver<T>() where T : class { using (new SessionIdLoggingContext(SessionId)) { Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-02 20:55:15 UTC (rev 4561) @@ -535,7 +535,7 @@ <Compile Include="Hql\Ast\ANTLR\Tree\ASTErrorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> - <Compile Include="ICriteriaOfT.cs" /> + <Compile Include="IQueryOver.cs" /> <Compile Include="Criterion\QueryOver.cs" /> <Compile Include="Impl\ExpressionProcessor.cs" /> <Compile Include="Impl\SessionIdLoggingContext.cs" /> Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -1,168 +0,0 @@ -using System; -using System.Collections; - -using NUnit.Framework; - -using NHibernate.Criterion; -using NHibernate.Transform; -using NHibernate.Type; -using NHibernate.Util; - -namespace NHibernate.Test.Criteria.Lambda -{ - - [TestFixture] - public class CriteriaOfTFixture : LambdaFixtureBase - { - - [Test] - public void SimpleCriterion_NoAlias() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .Add(Restrictions.Eq("Name", "test name")) - .Add(Restrictions.Not(Restrictions.Eq("Name", "not test name"))) - .Add(Restrictions.Gt("Age", 10)) - .Add(Restrictions.Ge("Age", 11)) - .Add(Restrictions.Lt("Age", 50)) - .Add(Restrictions.Le("Age", 49)); - - ICriteria<Person> actual = - CreateTestQueryOver<Person>() - .And(p => p.Name == "test name") - .And(p => p.Name != "not test name") - .And(p => p.Age > 10) - .And(p => p.Age >= 11) - .And(p => p.Age < 50) - .And(p => p.Age <= 49); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void PropertyCriterion_NoAlias() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .Add(Restrictions.EqProperty("Age", "Height")) - .Add(Restrictions.NotEqProperty("Age", "Height")) - .Add(Restrictions.GtProperty("Age", "Height")) - .Add(Restrictions.GeProperty("Age", "Height")) - .Add(Restrictions.LtProperty("Age", "Height")) - .Add(Restrictions.LeProperty("Age", "Height")); - - ICriteria<Person> actual = - CreateTestQueryOver<Person>() - .And(p => p.Age == p.Height) - .And(p => p.Age != p.Height) - .And(p => p.Age > p.Height) - .And(p => p.Age >= p.Height) - .And(p => p.Age < p.Height) - .And(p => p.Age <= p.Height); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void MultipleCriterionExpression() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .Add(Restrictions.And( - Restrictions.Eq("Name", "test name"), - Restrictions.Or( - Restrictions.Gt("Age", 21), - Restrictions.Eq("HasCar", true)))); - - ICriteria<Person> actual = - CreateTestQueryOver<Person>() - .Where(p => p.Name == "test name" && (p.Age > 21 || p.HasCar)); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void Where_BehavesTheSameAs_And() - { - Person personAlias = null; - QueryOver<Person> expected = (QueryOver<Person>) - CreateTestQueryOver<Person>(() => personAlias) - .And(() => personAlias.Name == "test name") - .And(p => p.Name == "test name"); - - ICriteria<Person> actual = - CreateTestQueryOver<Person>(() => personAlias) - .Where(() => personAlias.Name == "test name") - .Where(p => p.Name == "test name"); - - AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); - } - - [Test] - public void SimpleCriterion_AliasReferenceSyntax() - { - ICriteria expected = - CreateTestCriteria(typeof(Person), "personAlias") - .Add(Restrictions.Eq("personAlias.Name", "test name")); - - Person personAlias = null; - ICriteria<Person> actual = - CreateTestQueryOver<Person>(() => personAlias) - .Where(() => personAlias.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void SubCriteria_JoinWalk_ToOne() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .CreateCriteria("Father") - .Add(Expression.Eq("Name", "test name")); - - ICriteria<Person> actual = - CreateTestQueryOver<Person>() - .JoinWalk(p => p.Father) // sub-criteria - .Where(f => f.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void SubCriteria_JoinWalk_ToMany() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .CreateCriteria("Children") - .Add(Expression.Eq("Nickname", "test name")); - - ICriteria<Child> actual = - CreateTestQueryOver<Person>() - .JoinWalk<Child>(p => p.Children) // sub-criteria - .Where(c => c.Nickname == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - [Test] - public void Alias_Join() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .CreateAlias("Father", "fatherAlias") - .CreateAlias("Children", "childAlias"); - - Person fatherAlias = null; - Child childAlias = null; - ICriteria<Person> actual = - CreateTestQueryOver<Person>() - .Join(p => p.Father, () => fatherAlias) - .Join(p => p.Children, () => childAlias); - - AssertCriteriaAreEqual(expected, actual); - } - - } - -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -30,12 +30,12 @@ return new CriteriaImpl(persistentClass, alias, null); } - protected ICriteria<T> CreateTestQueryOver<T>() + protected IQueryOver<T> CreateTestQueryOver<T>() { return new QueryOver<T>(new CriteriaImpl(typeof(T), null)); } - protected ICriteria<T> CreateTestQueryOver<T>(Expression<Func<object>> alias) + protected IQueryOver<T> CreateTestQueryOver<T>(Expression<Func<object>> alias) { string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); return new QueryOver<T>(new CriteriaImpl(typeof(T), aliasContainer, null)); @@ -51,7 +51,7 @@ AssertObjectsAreEqual(expected, actual); } - protected void AssertCriteriaAreEqual<T>(ICriteria expected, ICriteria<T> actual) + protected void AssertCriteriaAreEqual<T>(ICriteria expected, IQueryOver<T> actual) { AssertObjectsAreEqual(expected, ((QueryOver<T>)actual).UnderlyingCriteria); } Copied: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs (from rev 4560, trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-02 20:55:15 UTC (rev 4561) @@ -0,0 +1,168 @@ +using System; +using System.Collections; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.Transform; +using NHibernate.Type; +using NHibernate.Util; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class QueryOverFixture : LambdaFixtureBase + { + + [Test] + public void SimpleCriterion_NoAlias() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.Eq("Name", "test name")) + .Add(Restrictions.Not(Restrictions.Eq("Name", "not test name"))) + .Add(Restrictions.Gt("Age", 10)) + .Add(Restrictions.Ge("Age", 11)) + .Add(Restrictions.Lt("Age", 50)) + .Add(Restrictions.Le("Age", 49)); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .And(p => p.Name == "test name") + .And(p => p.Name != "not test name") + .And(p => p.Age > 10) + .And(p => p.Age >= 11) + .And(p => p.Age < 50) + .And(p => p.Age <= 49); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void PropertyCriterion_NoAlias() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.EqProperty("Age", "Height")) + .Add(Restrictions.NotEqProperty("Age", "Height")) + .Add(Restrictions.GtProperty("Age", "Height")) + .Add(Restrictions.GeProperty("Age", "Height")) + .Add(Restrictions.LtProperty("Age", "Height")) + .Add(Restrictions.LeProperty("Age", "Height")); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .And(p => p.Age == p.Height) + .And(p => p.Age != p.Height) + .And(p => p.Age > p.Height) + .And(p => p.Age >= p.Height) + .And(p => p.Age < p.Height) + .And(p => p.Age <= p.Height); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void MultipleCriterionExpression() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.And( + Restrictions.Eq("Name", "test name"), + Restrictions.Or( + Restrictions.Gt("Age", 21), + Restrictions.Eq("HasCar", true)))); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test name" && (p.Age > 21 || p.HasCar)); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void Where_BehavesTheSameAs_And() + { + Person personAlias = null; + QueryOver<Person> expected = (QueryOver<Person>) + CreateTestQueryOver<Person>(() => personAlias) + .And(() => personAlias.Name == "test name") + .And(p => p.Name == "test name"); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name") + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); + } + + [Test] + public void SimpleCriterion_AliasReferenceSyntax() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .Add(Restrictions.Eq("personAlias.Name", "test name")); + + Person personAlias = null; + IQueryOver<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void SubCriteria_JoinWalk_ToOne() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Father") + .Add(Expression.Eq("Name", "test name")); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .JoinWalk(p => p.Father) // sub-criteria + .Where(f => f.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void SubCriteria_JoinWalk_ToMany() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Children") + .Add(Expression.Eq("Nickname", "test name")); + + IQueryOver<Child> actual = + CreateTestQueryOver<Person>() + .JoinWalk<Child>(p => p.Children) // sub-criteria + .Where(c => c.Nickname == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void Alias_Join() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .CreateAlias("Children", "childAlias"); + + Person fatherAlias = null; + Child childAlias = null; + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Join(p => p.Father, () => fatherAlias) + .Join(p => p.Children, () => childAlias); + + AssertCriteriaAreEqual(expected, actual); + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-02 04:24:50 UTC (rev 4560) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-02 20:55:15 UTC (rev 4561) @@ -147,7 +147,7 @@ <Compile Include="Criteria\DetachedCriteriaSerializable.cs" /> <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> - <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> + <Compile Include="Criteria\Lambda\QueryOverFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-02 21:02:40
|
Revision: 4562 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4562&view=rev Author: ricbrown Date: 2009-07-02 21:02:37 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Renamed JoinWalk to JoinQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 20:55:15 UTC (rev 4561) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 21:02:37 UTC (rev 4562) @@ -62,14 +62,14 @@ return Add(expression); } - public IQueryOver<U> JoinWalk<U>(Expression<Func<T, U>> path) + public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( ExpressionProcessor.FindMemberExpression(path.Body))); } - public IQueryOver<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) + public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-02 20:55:15 UTC (rev 4561) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-02 21:02:37 UTC (rev 4562) @@ -55,7 +55,7 @@ /// <typeparam name="U">Type of sub-criteria</typeparam> /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - IQueryOver<U> JoinWalk<U>(Expression<Func<T, U>> path); + IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path); /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity @@ -64,7 +64,7 @@ /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - IQueryOver<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path); + IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path); /// <summary> /// Join an association, assigning an alias to the joined entity Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-02 20:55:15 UTC (rev 4561) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-02 21:02:37 UTC (rev 4562) @@ -123,7 +123,7 @@ IQueryOver<Person> actual = CreateTestQueryOver<Person>() - .JoinWalk(p => p.Father) // sub-criteria + .JoinQueryOver(p => p.Father) // sub-criteria .Where(f => f.Name == "test name"); AssertCriteriaAreEqual(expected, actual); @@ -139,7 +139,7 @@ IQueryOver<Child> actual = CreateTestQueryOver<Person>() - .JoinWalk<Child>(p => p.Children) // sub-criteria + .JoinQueryOver<Child>(p => p.Children) // sub-criteria .Where(c => c.Nickname == "test name"); AssertCriteriaAreEqual(expected, actual); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-02 21:24:12
|
Revision: 4563 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4563&view=rev Author: ricbrown Date: 2009-07-02 21:24:11 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Migrated some more test coverage over from lambda extensions project. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-02 21:02:37 UTC (rev 4562) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-02 21:24:11 UTC (rev 4563) @@ -142,7 +142,12 @@ MethodCallExpression methodCallExpression = (MethodCallExpression)expression; if (methodCallExpression.Method.Name == "GetType") - return FindMemberExpression(methodCallExpression.Object) + ".class"; + { + if (methodCallExpression.Object.NodeType == ExpressionType.MemberAccess) + return FindMemberExpression(methodCallExpression.Object) + ".class"; + else + return "class"; + } throw new Exception("Unrecognised method call in epression " + expression.ToString()); } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-02 21:02:37 UTC (rev 4562) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-02 21:24:11 UTC (rev 4563) @@ -25,7 +25,8 @@ .Add(Restrictions.Gt("Age", 10)) .Add(Restrictions.Ge("Age", 11)) .Add(Restrictions.Lt("Age", 50)) - .Add(Restrictions.Le("Age", 49)); + .Add(Restrictions.Le("Age", 49)) + .Add(Restrictions.Eq("class", typeof(Person))); IQueryOver<Person> actual = CreateTestQueryOver<Person>() @@ -34,7 +35,8 @@ .And(p => p.Age > 10) .And(p => p.Age >= 11) .And(p => p.Age < 50) - .And(p => p.Age <= 49); + .And(p => p.Age <= 49) + .And(p => p.GetType() == typeof(Person)); AssertCriteriaAreEqual(expected, actual); } @@ -103,12 +105,24 @@ { ICriteria expected = CreateTestCriteria(typeof(Person), "personAlias") - .Add(Restrictions.Eq("personAlias.Name", "test name")); + .Add(Restrictions.Eq("personAlias.Name", "test name")) + .Add(Restrictions.Not(Restrictions.Eq("personAlias.Name", "not test name"))) + .Add(Restrictions.Gt("personAlias.Age", 10)) + .Add(Restrictions.Ge("personAlias.Age", 11)) + .Add(Restrictions.Lt("personAlias.Age", 50)) + .Add(Restrictions.Le("personAlias.Age", 49)) + .Add(Restrictions.Eq("personAlias.class", typeof(Person))); Person personAlias = null; IQueryOver<Person> actual = CreateTestQueryOver<Person>(() => personAlias) - .Where(() => personAlias.Name == "test name"); + .Where(() => personAlias.Name == "test name") + .And(() => personAlias.Name != "not test name") + .And(() => personAlias.Age > 10) + .And(() => personAlias.Age >= 11) + .And(() => personAlias.Age < 50) + .And(() => personAlias.Age <= 49) + .And(() => personAlias.GetType() == typeof(Person)); AssertCriteriaAreEqual(expected, actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-02 21:59:56
|
Revision: 4564 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4564&view=rev Author: ricbrown Date: 2009-07-02 21:59:53 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Implemented IQueryOver interface explicitly to maintain type on fluent methods. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 21:24:11 UTC (rev 4563) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-02 21:59:53 UTC (rev 4564) @@ -42,41 +42,41 @@ get { return _criteria; } } - public IQueryOver<T> And(Expression<Func<T, bool>> expression) + public QueryOver<T> And(Expression<Func<T, bool>> expression) { return Add(expression); } - public IQueryOver<T> And(Expression<Func<bool>> expression) + public QueryOver<T> And(Expression<Func<bool>> expression) { return Add(expression); } - public IQueryOver<T> Where(Expression<Func<T, bool>> expression) + public QueryOver<T> Where(Expression<Func<T, bool>> expression) { return Add(expression); } - public IQueryOver<T> Where(Expression<Func<bool>> expression) + public QueryOver<T> Where(Expression<Func<bool>> expression) { return Add(expression); } - public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( ExpressionProcessor.FindMemberExpression(path.Body))); } - public IQueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path) + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path) { return new QueryOver<U>(_impl, _criteria.CreateCriteria( ExpressionProcessor.FindMemberExpression(path.Body))); } - public IQueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + public QueryOver<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) { return AddAlias( ExpressionProcessor.FindMemberExpression(path.Body), @@ -89,6 +89,9 @@ return _criteria.List<T>(); } + /// <summary> + /// Get an executable instance of <c>IQueryOver<T></c>, + /// to actually run the query.</summary> public IQueryOver<T> GetExecutableQueryOver(ISession session) { _impl.Session = session.GetSessionImplementation(); @@ -113,6 +116,28 @@ return this; } + + IQueryOver<T> IQueryOver<T>.And(Expression<Func<T, bool>> expression) + { return And(expression); } + + IQueryOver<T> IQueryOver<T>.And(Expression<Func<bool>> expression) + { return And(expression); } + + IQueryOver<T> IQueryOver<T>.Where(Expression<Func<T, bool>> expression) + { return Where(expression); } + + IQueryOver<T> IQueryOver<T>.Where(Expression<Func<bool>> expression) + { return Where(expression); } + + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) + { return JoinQueryOver(path); } + + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path) + { return JoinQueryOver(path); } + + IQueryOver<T> IQueryOver<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + { return Join(path, alias); } + } } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-02 21:24:11 UTC (rev 4563) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-02 21:59:53 UTC (rev 4564) @@ -80,11 +80,6 @@ /// <returns>The list filled with the results.</returns> IList<T> List(); - /// <summary> - /// Get an executable instance of <c>Criteria<T></c>, - /// to actually run the query.</summary> - IQueryOver<T> GetExecutableQueryOver(ISession session); - } } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-02 21:24:11 UTC (rev 4563) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-02 21:59:53 UTC (rev 4564) @@ -79,7 +79,7 @@ using (ISession s = OpenSession()) { - var personQuery = + QueryOver<Person> personQuery = new QueryOver<Person>() .Where(p => p.Name == "test person 1"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-04 05:07:04
|
Revision: 4568 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4568&view=rev Author: fabiomaulo Date: 2009-07-04 05:06:59 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Merge r4567 (fix NH-1864) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-07-04 05:03:54 UTC (rev 4567) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-07-04 05:06:59 UTC (rev 4568) @@ -69,18 +69,22 @@ public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) { - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + // NH Different behaviour NH-1776 + // Analyze all named parameters declared after filters + //in general all named parameters but depend on the complexity of the query + foreach (ParameterInfo entry in _namedParameters.Values) { - foreach (ParameterInfo entry in _namedParameters.Values) + int amountOfPush = 0; + foreach (int existingParameterLocation in parameters.FilteredParameterLocations) { - for (int index = 0; index < entry.SqlLocations.Length; index++) + // a parameter span, at least, one value; where span more than one all values are cosecutive + // the first position determines the position of the others values + if (entry.SqlLocations[0] >= existingParameterLocation) { - if (entry.SqlLocations[index] >= existingParameterLocation) - { - entry.IncrementLocation(index); - } + amountOfPush++; } } + entry.IncrementLocation(amountOfPush); } } @@ -165,9 +169,16 @@ public IType ExpectedType { get; private set; } - public void IncrementLocation(int index) + public void IncrementLocation(int amountOfPush) { - sqlLocations[index] = originalLocation[index] + 1; + if(amountOfPush <= 0) + { + return; // short cut + } + for (int i = 0; i < sqlLocations.Length; i++) + { + sqlLocations[i] = originalLocation[i] + amountOfPush; + } } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs 2009-07-04 05:06:59 UTC (rev 4568) @@ -0,0 +1,50 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1864 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void ExecuteQuery(Action<ISession> sessionModifier) + { + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + sessionModifier(session); + session.CreateQuery( + @"select cat + from Invoice inv, Category cat + where cat.ValidUntil = :now and inv.Foo = :foo + ") + .SetInt32("foo", 42).SetDateTime("now", DateTime.Now).List(); + + tx.Commit(); + } + } + } + + [Test] + public void Bug() + { + Assert.DoesNotThrow(() => ExecuteQuery(s=> s.EnableFilter("validity").SetParameter("date", DateTime.Now))); + } + + [Test] + public void FilterOnOffOn() + { + Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now))); + Assert.DoesNotThrow(() => ExecuteQuery(s => { })); + Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now))); + } + + [Test] + public void FilterQueryTwice() + { + Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now))); + Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now))); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml 2009-07-04 05:06:59 UTC (rev 4568) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1864"> + + <class name="Category"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + <property name="ValidUntil" type="DateTime" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + <property name="Foo" type="Int32" /> + <property name="ValidUntil" type="DateTime" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <filter-def name="validity"> + <filter-param name="date" type="DateTime"/> + </filter-def> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs 2009-07-04 05:06:59 UTC (rev 4568) @@ -0,0 +1,17 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1864 +{ + public class Category + { + public virtual int ID { get; private set; } + public virtual DateTime ValidUntil { get; set; } + } + + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime ValidUntil { get; set; } + public virtual int Foo { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 05:03:54 UTC (rev 4567) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 05:06:59 UTC (rev 4568) @@ -533,6 +533,8 @@ <Compile Include="NHSpecificTest\NH1849\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1850\Customer.cs" /> <Compile Include="NHSpecificTest\NH1850\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1864\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1864\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1944,6 +1946,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1864\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1850\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1192\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-04 15:45:58
|
Revision: 4570 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4570&view=rev Author: fabiomaulo Date: 2009-07-04 15:45:57 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Merge r4569 (fix NH-1859) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/SampleTest.cs Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-07-04 15:42:33 UTC (rev 4569) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-07-04 15:45:57 UTC (rev 4570) @@ -56,7 +56,7 @@ // check comments if (indx + 1 < stringLength && sqlString.Substring(indx,2) == "/*") { - var closeCommentIdx = sqlString.IndexOf("*/"); + var closeCommentIdx = sqlString.IndexOf("*/", indx+2); recognizer.Other(sqlString.Substring(indx, (closeCommentIdx- indx)+2)); indx = closeCommentIdx + 1; continue; Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/DomainClass.cs 2009-07-04 15:45:57 UTC (rev 4570) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.NHSpecificTest.NH1859 +{ + public class DomainClass + { + public int Id { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/Mappings.hbm.xml 2009-07-04 15:45:57 UTC (rev 4570) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1859" + default-lazy="false"> + <class name="DomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1859/SampleTest.cs 2009-07-04 15:45:57 UTC (rev 4570) @@ -0,0 +1,40 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1859 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + session.Save(new DomainClass {Id = 1}); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + session.Delete("from DomainClass"); + session.Flush(); + } + } + + [Test] + public void NativeQueryWithTwoComments() + { + using (ISession session = OpenSession()) + { + IQuery qry = session.CreateSQLQuery("select /* first comment */ o.* /* second comment*/ from domainclass o") + .AddEntity("o", typeof (DomainClass)); + var res = qry.List<DomainClass>(); + Assert.AreEqual(res[0].Id, 1); + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 15:42:33 UTC (rev 4569) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 15:45:57 UTC (rev 4570) @@ -533,6 +533,8 @@ <Compile Include="NHSpecificTest\NH1849\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1850\Customer.cs" /> <Compile Include="NHSpecificTest\NH1850\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1859\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1859\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1864\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1864\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> @@ -1946,6 +1948,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1859\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1864\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1850\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-04 18:58:09
|
Revision: 4573 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4573&view=rev Author: fabiomaulo Date: 2009-07-04 18:58:06 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Merge r4572 (fix NH-1857) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Department.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Employee.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/FullJoinTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-07-04 18:53:07 UTC (rev 4572) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-07-04 18:58:06 UTC (rev 4573) @@ -54,6 +54,8 @@ return JoinType.InnerJoin; case HqlSqlWalker.RIGHT_OUTER: return JoinType.RightOuterJoin; + case HqlSqlWalker.FULL: + return JoinType.FullJoin; default: throw new AssertionFailure("undefined join type " + astJoinType); } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Department.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Department.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Department.cs 2009-07-04 18:58:06 UTC (rev 4573) @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1857 +{ + public class Department + { + private Department() {} + + public Department(int id, string name) + { + Id = id; + Name = name; + } + + public int Id { get; private set; } + + public string Name { get; set; } + + private ISet<Employee> _employees = new HashedSet<Employee>(); + + public ReadOnlyCollection<Employee> Employees + { + get { return new List<Employee>(_employees).AsReadOnly(); } + } + + public void AddEmployee(Employee e) + { + if (e != null && !_employees.Contains(e)) + { + e.Department = this; + _employees.Add(e); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Employee.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Employee.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Employee.cs 2009-07-04 18:58:06 UTC (rev 4573) @@ -0,0 +1,24 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1857 +{ + public class Employee + { + private Employee() {} + + public Employee(int id, string name, DateTime d) + { + Id = id; + Name = name; + CompanyJoinDate = d; + } + + public int Id { get; private set; } + + public string Name { get; set; } + + public DateTime CompanyJoinDate { get; set; } + + public Department Department { get; internal set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/FullJoinTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/FullJoinTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/FullJoinTest.cs 2009-07-04 18:58:06 UTC (rev 4573) @@ -0,0 +1,58 @@ +using System; +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1857 +{ + [TestFixture] + public class FullJoinTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + var e1 = new Employee(1, "Employee1", new DateTime(1995, 1, 1)); + var e2 = new Employee(2, "Employee2", new DateTime(2007, 8, 1)); + var e3 = new Employee(3, "Employee3", new DateTime(2009, 5, 1)); + + var d1 = new Department(1, "Department S"); + + d1.AddEmployee(e1); + d1.AddEmployee(e2); + + session.SaveOrUpdate(d1); + session.SaveOrUpdate(e1); + session.SaveOrUpdate(e2); + session.SaveOrUpdate(e3); + + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + using (ITransaction t = session.BeginTransaction()) + { + session.CreateQuery("delete from Employee").ExecuteUpdate(); + session.CreateQuery("delete from Department").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void TestFullJoin() + { + using (ISession s = OpenSession()) + { + IQuery q = s.CreateQuery("from Employee as e full join e.Department"); + + IList result = q.List(); + + Assert.AreEqual(3, result.Count); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1857/Mappings.hbm.xml 2009-07-04 18:58:06 UTC (rev 4573) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1857" + default-lazy="false"> + <class name="Department"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <set name="Employees" access="field.camelcase-underscore" inverse="true" + cascade="all-delete-orphan" lazy="false"> + <key column="DepartmentId" /> + <one-to-many class="Employee"/> + </set> + </class> + + <class name="Employee"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <property name="CompanyJoinDate" /> + + <many-to-one name="Department" class="Department" /> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 18:53:07 UTC (rev 4572) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 18:58:06 UTC (rev 4573) @@ -532,6 +532,9 @@ <Compile Include="NHSpecificTest\NH1849\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1850\Customer.cs" /> <Compile Include="NHSpecificTest\NH1850\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1857\Department.cs" /> + <Compile Include="NHSpecificTest\NH1857\Employee.cs" /> + <Compile Include="NHSpecificTest\NH1857\FullJoinTest.cs" /> <Compile Include="NHSpecificTest\NH1859\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1859\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1864\Fixture.cs" /> @@ -1947,6 +1950,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1857\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1859\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1864\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-04 23:30:14
|
Revision: 4574 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4574&view=rev Author: ricbrown Date: 2009-07-04 23:30:11 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Added ordering to IQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-04 18:58:06 UTC (rev 4573) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-04 23:30:11 UTC (rev 4574) @@ -62,6 +62,26 @@ return Add(expression); } + public QueryOver<T> OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + { + return AddOrder(path, orderDelegate); + } + + public QueryOver<T> OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + { + return AddOrder(path, orderDelegate); + } + + public QueryOver<T> ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + { + return AddOrder(path, orderDelegate); + } + + public QueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + { + return AddOrder(path, orderDelegate); + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -116,7 +136,19 @@ return this; } + private QueryOver<T> AddOrder(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + { + _criteria.AddOrder(ExpressionProcessor.ProcessOrder<T>(path, orderDelegate)); + return this; + } + private QueryOver<T> AddOrder(Expression<Func<object>> path, Func<string, Order> orderDelegate) + { + _criteria.AddOrder(ExpressionProcessor.ProcessOrder(path, orderDelegate)); + return this; + } + + IQueryOver<T> IQueryOver<T>.And(Expression<Func<T, bool>> expression) { return And(expression); } @@ -129,6 +161,18 @@ IQueryOver<T> IQueryOver<T>.Where(Expression<Func<bool>> expression) { return Where(expression); } + IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + { return OrderBy(path, orderDelegate); } + + IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + { return OrderBy(path, orderDelegate); } + + IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + { return ThenBy(path, orderDelegate); } + + IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + { return ThenBy(path, orderDelegate); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-04 18:58:06 UTC (rev 4573) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-04 23:30:11 UTC (rev 4574) @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq.Expressions; +using NHibernate.Criterion; + namespace NHibernate { @@ -50,6 +52,42 @@ IQueryOver<T> Where(Expression<Func<bool>> expression); /// <summary> + /// Add order expressed as a lambda expression + /// </summary> + /// <typeparam name="T">Type (same as criteria type)</typeparam> + /// <param name="expression">Lambda expression</param> + /// <param name="orderDelegate">Order delegate (direction)</param> + /// <returns>criteria instance</returns> + IQueryOver<T> OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate); + + /// <summary> + /// Add order expressed as a lambda expression + /// </summary> + /// <typeparam name="T">Type (same as criteria type)</typeparam> + /// <param name="expression">Lambda expression</param> + /// <param name="orderDelegate">Order delegate (direction)</param> + /// <returns>criteria instance</returns> + IQueryOver<T> OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate); + + /// <summary> + /// Add order expressed as a lambda expression + /// </summary> + /// <typeparam name="T">Type (same as criteria type)</typeparam> + /// <param name="expression">Lambda expression</param> + /// <param name="orderDelegate">Order delegate (direction)</param> + /// <returns>criteria instance</returns> + IQueryOver<T> ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate); + + /// <summary> + /// Add order expressed as a lambda expression + /// </summary> + /// <typeparam name="T">Type (same as criteria type)</typeparam> + /// <param name="expression">Lambda expression</param> + /// <param name="orderDelegate">Order delegate (direction)</param> + /// <returns>criteria instance</returns> + IQueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-04 18:58:06 UTC (rev 4573) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-04 23:30:11 UTC (rev 4574) @@ -177,6 +177,27 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void OrderBy() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .AddOrder(Order.Asc("Name")) + .AddOrder(Order.Desc("Age")) + .AddOrder(Order.Desc("personAlias.Name")) + .AddOrder(Order.Asc("personAlias.Age")); + + Person personAlias = null; + IQueryOver<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .OrderBy(p => p.Name, Order.Asc) + .ThenBy(p => p.Age, Order.Desc) + .ThenBy(() => personAlias.Name, Order.Desc) + .ThenBy(() => personAlias.Age, Order.Asc); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-07-04 23:39:52
|
Revision: 4575 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4575&view=rev Author: steverstrong Date: 2009-07-04 23:39:49 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Fix for NH1849, plus some improvement to AST error reporting Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.g Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-07-04 23:30:11 UTC (rev 4574) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-07-04 23:39:49 UTC (rev 4575) @@ -1,4 +1,4 @@ -// $ANTLR 3.1.2 /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g 2009-06-20 02:19:12 +// $ANTLR 3.1.2 /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g 2009-07-05 00:59:40 // The variable 'variable' is assigned but its value is never used. #pragma warning disable 168, 219 @@ -350,7 +350,7 @@ } override public string GrammarFileName { - get { return "/Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g"; } + get { return "/Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g"; } } @@ -365,7 +365,7 @@ }; // $ANTLR start "statement" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:40:1: statement : ( selectStatement | updateStatement | deleteStatement | insertStatement ); + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:40:1: statement : ( selectStatement | updateStatement | deleteStatement | insertStatement ); public HqlSqlWalker.statement_return statement() // throws RecognitionException [1] { HqlSqlWalker.statement_return retval = new HqlSqlWalker.statement_return(); @@ -388,7 +388,7 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:2: ( selectStatement | updateStatement | deleteStatement | insertStatement ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:2: ( selectStatement | updateStatement | deleteStatement | insertStatement ) int alt1 = 4; switch ( input.LA(1) ) { @@ -423,7 +423,7 @@ switch (alt1) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:4: selectStatement + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:4: selectStatement { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -437,7 +437,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:22: updateStatement + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:22: updateStatement { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -451,7 +451,7 @@ } break; case 3 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:40: deleteStatement + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:40: deleteStatement { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -465,7 +465,7 @@ } break; case 4 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:58: insertStatement + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:41:58: insertStatement { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -506,7 +506,7 @@ }; // $ANTLR start "selectStatement" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:44:1: selectStatement : query ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:44:1: selectStatement : query ; public HqlSqlWalker.selectStatement_return selectStatement() // throws RecognitionException [1] { HqlSqlWalker.selectStatement_return retval = new HqlSqlWalker.selectStatement_return(); @@ -523,8 +523,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:45:2: ( query ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:45:4: query + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:45:2: ( query ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:45:4: query { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -563,7 +563,7 @@ }; // $ANTLR start "updateStatement" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:51:1: updateStatement : ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:51:1: updateStatement : ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ; public HqlSqlWalker.updateStatement_return updateStatement() // throws RecognitionException [1] { HqlSqlWalker.updateStatement_return retval = new HqlSqlWalker.updateStatement_return(); @@ -592,8 +592,8 @@ RewriteRuleSubtreeStream stream_setClause = new RewriteRuleSubtreeStream(adaptor,"rule setClause"); try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:2: ( ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:4: ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:2: ( ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:4: ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) { _last = (IASTNode)input.LT(1); { @@ -607,7 +607,7 @@ BeforeStatement( "update", UPDATE ); Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:57: (v= VERSIONED )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:57: (v= VERSIONED )? int alt2 = 2; int LA2_0 = input.LA(1); @@ -618,7 +618,7 @@ switch (alt2) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:58: v= VERSIONED + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:58: v= VERSIONED { _last = (IASTNode)input.LT(1); v=(IASTNode)Match(input,VERSIONED,FOLLOW_VERSIONED_in_updateStatement222); @@ -642,7 +642,7 @@ state.followingStackPointer--; stream_setClause.Add(s.Tree); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:97: (w= whereClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:97: (w= whereClause )? int alt3 = 2; int LA3_0 = input.LA(1); @@ -653,7 +653,7 @@ switch (alt3) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:98: w= whereClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:58:98: w= whereClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_whereClause_in_updateStatement237); @@ -674,7 +674,7 @@ // AST REWRITE - // elements: w, f, s, u + // elements: w, s, u, f // token labels: u // rule labels: w, f, retval, s // token list labels: @@ -690,14 +690,14 @@ root_0 = (IASTNode)adaptor.GetNilNode(); // 59:3: -> ^( $u $f $s ( $w)? ) { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:59:6: ^( $u $f $s ( $w)? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:59:6: ^( $u $f $s ( $w)? ) { IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); root_1 = (IASTNode)adaptor.BecomeRoot(stream_u.NextNode(), root_1); adaptor.AddChild(root_1, stream_f.NextTree()); adaptor.AddChild(root_1, stream_s.NextTree()); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:59:17: ( $w)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:59:17: ( $w)? if ( stream_w.HasNext() ) { adaptor.AddChild(root_1, stream_w.NextTree()); @@ -745,7 +745,7 @@ }; // $ANTLR start "deleteStatement" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:62:1: deleteStatement : ^( DELETE fromClause ( whereClause )? ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:62:1: deleteStatement : ^( DELETE fromClause ( whereClause )? ) ; public HqlSqlWalker.deleteStatement_return deleteStatement() // throws RecognitionException [1] { HqlSqlWalker.deleteStatement_return retval = new HqlSqlWalker.deleteStatement_return(); @@ -766,8 +766,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:2: ( ^( DELETE fromClause ( whereClause )? ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:4: ^( DELETE fromClause ( whereClause )? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:2: ( ^( DELETE fromClause ( whereClause )? ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:4: ^( DELETE fromClause ( whereClause )? ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -791,7 +791,7 @@ state.followingStackPointer--; adaptor.AddChild(root_1, fromClause7.Tree); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:66: ( whereClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:66: ( whereClause )? int alt4 = 2; int LA4_0 = input.LA(1); @@ -802,7 +802,7 @@ switch (alt4) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:67: whereClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:68:67: whereClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_whereClause_in_deleteStatement287); @@ -854,7 +854,7 @@ }; // $ANTLR start "insertStatement" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:71:1: insertStatement : ^( INSERT intoClause query ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:71:1: insertStatement : ^( INSERT intoClause query ) ; public HqlSqlWalker.insertStatement_return insertStatement() // throws RecognitionException [1] { HqlSqlWalker.insertStatement_return retval = new HqlSqlWalker.insertStatement_return(); @@ -875,8 +875,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:80:2: ( ^( INSERT intoClause query ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:80:4: ^( INSERT intoClause query ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:80:2: ( ^( INSERT intoClause query ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:80:4: ^( INSERT intoClause query ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -944,7 +944,7 @@ }; // $ANTLR start "intoClause" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:83:1: intoClause : ^( INTO (p= path ) ps= insertablePropertySpec ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:83:1: intoClause : ^( INTO (p= path ) ps= insertablePropertySpec ) ; public HqlSqlWalker.intoClause_return intoClause() // throws RecognitionException [1] { HqlSqlWalker.intoClause_return retval = new HqlSqlWalker.intoClause_return(); @@ -965,8 +965,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:2: ( ^( INTO (p= path ) ps= insertablePropertySpec ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:4: ^( INTO (p= path ) ps= insertablePropertySpec ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:2: ( ^( INTO (p= path ) ps= insertablePropertySpec ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:4: ^( INTO (p= path ) ps= insertablePropertySpec ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -984,8 +984,8 @@ HandleClauseStart( INTO ); Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:43: (p= path ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:44: p= path + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:43: (p= path ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:87:44: p= path { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_path_in_intoClause354); @@ -1038,7 +1038,7 @@ }; // $ANTLR start "insertablePropertySpec" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:90:1: insertablePropertySpec : ^( RANGE ( IDENT )+ ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:90:1: insertablePropertySpec : ^( RANGE ( IDENT )+ ) ; public HqlSqlWalker.insertablePropertySpec_return insertablePropertySpec() // throws RecognitionException [1] { HqlSqlWalker.insertablePropertySpec_return retval = new HqlSqlWalker.insertablePropertySpec_return(); @@ -1057,8 +1057,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:2: ( ^( RANGE ( IDENT )+ ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:4: ^( RANGE ( IDENT )+ ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:2: ( ^( RANGE ( IDENT )+ ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:4: ^( RANGE ( IDENT )+ ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1075,7 +1075,7 @@ Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:13: ( IDENT )+ + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:13: ( IDENT )+ int cnt5 = 0; do { @@ -1091,7 +1091,7 @@ switch (alt5) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:14: IDENT + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:91:14: IDENT { _last = (IASTNode)input.LT(1); IDENT14=(IASTNode)Match(input,IDENT,FOLLOW_IDENT_in_insertablePropertySpec378); @@ -1148,7 +1148,7 @@ }; // $ANTLR start "setClause" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:94:1: setClause : ^( SET ( assignment )* ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:94:1: setClause : ^( SET ( assignment )* ) ; public HqlSqlWalker.setClause_return setClause() // throws RecognitionException [1] { HqlSqlWalker.setClause_return retval = new HqlSqlWalker.setClause_return(); @@ -1167,8 +1167,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:2: ( ^( SET ( assignment )* ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:4: ^( SET ( assignment )* ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:2: ( ^( SET ( assignment )* ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:4: ^( SET ( assignment )* ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1188,7 +1188,7 @@ if ( input.LA(1) == Token.DOWN ) { Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:41: ( assignment )* + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:41: ( assignment )* do { int alt6 = 2; @@ -1203,7 +1203,7 @@ switch (alt6) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:42: assignment + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:95:42: assignment { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_assignment_in_setClause400); @@ -1257,7 +1257,7 @@ }; // $ANTLR start "assignment" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:98:1: assignment : ^( EQ (p= propertyRef ) ( newValue ) ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:98:1: assignment : ^( EQ (p= propertyRef ) ( newValue ) ) ; public HqlSqlWalker.assignment_return assignment() // throws RecognitionException [1] { HqlSqlWalker.assignment_return retval = new HqlSqlWalker.assignment_return(); @@ -1278,8 +1278,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:2: ( ^( EQ (p= propertyRef ) ( newValue ) ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:4: ^( EQ (p= propertyRef ) ( newValue ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:2: ( ^( EQ (p= propertyRef ) ( newValue ) ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:4: ^( EQ (p= propertyRef ) ( newValue ) ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1296,8 +1296,8 @@ Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:10: (p= propertyRef ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:11: p= propertyRef + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:10: (p= propertyRef ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:11: p= propertyRef { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_propertyRef_in_assignment432); @@ -1309,8 +1309,8 @@ } Resolve(((p != null) ? ((IASTNode)p.Tree) : null)); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:48: ( newValue ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:49: newValue + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:48: ( newValue ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:104:49: newValue { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_newValue_in_assignment438); @@ -1357,7 +1357,7 @@ }; // $ANTLR start "newValue" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:108:1: newValue : ( expr | query ); + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:108:1: newValue : ( expr | query ); public HqlSqlWalker.newValue_return newValue() // throws RecognitionException [1] { HqlSqlWalker.newValue_return retval = new HqlSqlWalker.newValue_return(); @@ -1376,7 +1376,7 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:2: ( expr | query ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:2: ( expr | query ) int alt7 = 2; int LA7_0 = input.LA(1); @@ -1398,7 +1398,7 @@ switch (alt7) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:4: expr + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:4: expr { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1412,7 +1412,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:11: query + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:109:11: query { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1453,7 +1453,7 @@ }; // $ANTLR start "query" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:112:1: query : ( unionedQuery | ^( UNION unionedQuery query ) ); + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:112:1: query : ( unionedQuery | ^( UNION unionedQuery query ) ); public HqlSqlWalker.query_return query() // throws RecognitionException [1] { HqlSqlWalker.query_return retval = new HqlSqlWalker.query_return(); @@ -1476,7 +1476,7 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:113:2: ( unionedQuery | ^( UNION unionedQuery query ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:113:2: ( unionedQuery | ^( UNION unionedQuery query ) ) int alt8 = 2; int LA8_0 = input.LA(1); @@ -1498,7 +1498,7 @@ switch (alt8) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:113:4: unionedQuery + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:113:4: unionedQuery { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1512,7 +1512,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:114:4: ^( UNION unionedQuery query ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:114:4: ^( UNION unionedQuery query ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1576,7 +1576,7 @@ }; // $ANTLR start "unionedQuery" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:119:1: unionedQuery : ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:119:1: unionedQuery : ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ; public HqlSqlWalker.unionedQuery_return unionedQuery() // throws RecognitionException [1] { HqlSqlWalker.unionedQuery_return retval = new HqlSqlWalker.unionedQuery_return(); @@ -1611,8 +1611,8 @@ RewriteRuleSubtreeStream stream_groupClause = new RewriteRuleSubtreeStream(adaptor,"rule groupClause"); try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:126:2: ( ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:126:4: ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:126:2: ( ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:126:4: ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) { _last = (IASTNode)input.LT(1); { @@ -1643,7 +1643,7 @@ state.followingStackPointer--; stream_fromClause.Add(f.Tree); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:130:5: (s= selectClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:130:5: (s= selectClause )? int alt9 = 2; int LA9_0 = input.LA(1); @@ -1654,7 +1654,7 @@ switch (alt9) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:130:6: s= selectClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:130:6: s= selectClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_selectClause_in_unionedQuery532); @@ -1672,7 +1672,7 @@ Match(input, Token.UP, null); adaptor.AddChild(root_1, root_2);_last = _save_last_2; } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:132:4: (w= whereClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:132:4: (w= whereClause )? int alt10 = 2; int LA10_0 = input.LA(1); @@ -1683,7 +1683,7 @@ switch (alt10) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:132:5: w= whereClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:132:5: w= whereClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_whereClause_in_unionedQuery547); @@ -1697,7 +1697,7 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:133:4: (g= groupClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:133:4: (g= groupClause )? int alt11 = 2; int LA11_0 = input.LA(1); @@ -1708,7 +1708,7 @@ switch (alt11) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:133:5: g= groupClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:133:5: g= groupClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_groupClause_in_unionedQuery557); @@ -1722,7 +1722,7 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:134:4: (o= orderClause )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:134:4: (o= orderClause )? int alt12 = 2; int LA12_0 = input.LA(1); @@ -1733,7 +1733,7 @@ switch (alt12) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:134:5: o= orderClause + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:134:5: o= orderClause { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_orderClause_in_unionedQuery567); @@ -1754,7 +1754,7 @@ // AST REWRITE - // elements: w, s, g, f, o + // elements: f, w, s, o, g // token labels: // rule labels: o, w, f, retval, g, s // token list labels: @@ -1771,12 +1771,12 @@ root_0 = (IASTNode)adaptor.GetNilNode(); // 136:2: -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:5: ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:5: ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) { IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(SELECT, "SELECT"), root_1); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:14: ( $s)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:14: ( $s)? if ( stream_s.HasNext() ) { adaptor.AddChild(root_1, stream_s.NextTree()); @@ -1784,21 +1784,21 @@ } stream_s.Reset(); adaptor.AddChild(root_1, stream_f.NextTree()); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:21: ( $w)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:21: ( $w)? if ( stream_w.HasNext() ) { adaptor.AddChild(root_1, stream_w.NextTree()); } stream_w.Reset(); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:25: ( $g)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:25: ( $g)? if ( stream_g.HasNext() ) { adaptor.AddChild(root_1, stream_g.NextTree()); } stream_g.Reset(); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:29: ( $o)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:136:29: ( $o)? if ( stream_o.HasNext() ) { adaptor.AddChild(root_1, stream_o.NextTree()); @@ -1846,7 +1846,7 @@ }; // $ANTLR start "orderClause" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:139:1: orderClause : ^( ORDER orderExprs ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:139:1: orderClause : ^( ORDER orderExprs ) ; public HqlSqlWalker.orderClause_return orderClause() // throws RecognitionException [1] { HqlSqlWalker.orderClause_return retval = new HqlSqlWalker.orderClause_return(); @@ -1865,8 +1865,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:140:2: ( ^( ORDER orderExprs ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:140:4: ^( ORDER orderExprs ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:140:2: ( ^( ORDER orderExprs ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:140:4: ^( ORDER orderExprs ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1923,7 +1923,7 @@ }; // $ANTLR start "orderExprs" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:143:1: orderExprs : expr ( ASCENDING | DESCENDING )? ( orderExprs )? ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:143:1: orderExprs : expr ( ASCENDING | DESCENDING )? ( orderExprs )? ; public HqlSqlWalker.orderExprs_return orderExprs() // throws RecognitionException [1] { HqlSqlWalker.orderExprs_return retval = new HqlSqlWalker.orderExprs_return(); @@ -1944,8 +1944,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:2: ( expr ( ASCENDING | DESCENDING )? ( orderExprs )? ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:4: expr ( ASCENDING | DESCENDING )? ( orderExprs )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:2: ( expr ( ASCENDING | DESCENDING )? ( orderExprs )? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:4: expr ( ASCENDING | DESCENDING )? ( orderExprs )? { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1955,7 +1955,7 @@ state.followingStackPointer--; adaptor.AddChild(root_0, expr29.Tree); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:9: ( ASCENDING | DESCENDING )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:9: ( ASCENDING | DESCENDING )? int alt13 = 2; int LA13_0 = input.LA(1); @@ -1966,7 +1966,7 @@ switch (alt13) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g: + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g: { _last = (IASTNode)input.LT(1); set30 = (IASTNode)input.LT(1); @@ -1992,7 +1992,7 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:37: ( orderExprs )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:37: ( orderExprs )? int alt14 = 2; int LA14_0 = input.LA(1); @@ -2003,7 +2003,7 @@ switch (alt14) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:38: orderExprs + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:144:38: orderExprs { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_orderExprs_in_orderExprs642); @@ -2046,7 +2046,7 @@ }; // $ANTLR start "groupClause" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:147:1: groupClause : ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:147:1: groupClause : ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ; public HqlSqlWalker.groupClause_return groupClause() // throws RecognitionException [1] { HqlSqlWalker.groupClause_return retval = new HqlSqlWalker.groupClause_return(); @@ -2069,8 +2069,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:2: ( ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:4: ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:2: ( ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:4: ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2088,7 +2088,7 @@ HandleClauseStart( GROUP ); Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:44: ( expr )+ + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:44: ( expr )+ int cnt15 = 0; do { @@ -2104,7 +2104,7 @@ switch (alt15) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:45: expr + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:45: expr { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_expr_in_groupClause661); @@ -2128,7 +2128,7 @@ loop15: ; // Stops C# compiler whinging that label 'loop15' has no statements - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:52: ( ^( HAVING logicalExpr ) )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:52: ( ^( HAVING logicalExpr ) )? int alt16 = 2; int LA16_0 = input.LA(1); @@ -2139,7 +2139,7 @@ switch (alt16) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:54: ^( HAVING logicalExpr ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:148:54: ^( HAVING logicalExpr ) { _last = (IASTNode)input.LT(1); { @@ -2203,7 +2203,7 @@ }; // $ANTLR start "selectClause" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:151:1: selectClause : ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:151:1: selectClause : ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ; public HqlSqlWalker.selectClause_return selectClause() // throws RecognitionException [1] { HqlSqlWalker.selectClause_return retval = new HqlSqlWalker.selectClause_return(); @@ -2226,8 +2226,8 @@ RewriteRuleSubtreeStream stream_selectExprList = new RewriteRuleSubtreeStream(adaptor,"rule selectExprList"); try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:2: ( ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:4: ^( SELECT (d= DISTINCT )? x= selectExprList ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:2: ( ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:4: ^( SELECT (d= DISTINCT )? x= selectExprList ) { _last = (IASTNode)input.LT(1); { @@ -2241,7 +2241,7 @@ HandleClauseStart( SELECT ); BeforeSelectClause(); Match(input, Token.DOWN, null); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:68: (d= DISTINCT )? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:68: (d= DISTINCT )? int alt17 = 2; int LA17_0 = input.LA(1); @@ -2252,7 +2252,7 @@ switch (alt17) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:69: d= DISTINCT + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:152:69: d= DISTINCT { _last = (IASTNode)input.LT(1); d=(IASTNode)Match(input,DISTINCT,FOLLOW_DISTINCT_in_selectClause696); @@ -2291,12 +2291,12 @@ root_0 = (IASTNode)adaptor.GetNilNode(); // 153:2: -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:153:5: ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:153:5: ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) { IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(SELECT_CLAUSE, "{select clause}"), root_1); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:153:40: ( $d)? + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:153:40: ( $d)? if ( stream_d.HasNext() ) { adaptor.AddChild(root_1, stream_d.NextNode()); @@ -2339,7 +2339,7 @@ }; // $ANTLR start "selectExprList" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:156:1: selectExprList : ( selectExpr | aliasedSelectExpr )+ ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:156:1: selectExprList : ( selectExpr | aliasedSelectExpr )+ ; public HqlSqlWalker.selectExprList_return selectExprList() // throws RecognitionException [1] { HqlSqlWalker.selectExprList_return retval = new HqlSqlWalker.selectExprList_return(); @@ -2362,12 +2362,12 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:2: ( ( selectExpr | aliasedSelectExpr )+ ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:4: ( selectExpr | aliasedSelectExpr )+ + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:2: ( ( selectExpr | aliasedSelectExpr )+ ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:4: ( selectExpr | aliasedSelectExpr )+ { root_0 = (IASTNode)adaptor.GetNilNode(); - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:4: ( selectExpr | aliasedSelectExpr )+ + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:4: ( selectExpr | aliasedSelectExpr )+ int cnt18 = 0; do { @@ -2387,7 +2387,7 @@ switch (alt18) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:6: selectExpr + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:6: selectExpr { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_selectExpr_in_selectExprList737); @@ -2399,7 +2399,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:19: aliasedSelectExpr + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:160:19: aliasedSelectExpr { _last = (IASTNode)input.LT(1); PushFollow(FOLLOW_aliasedSelectExpr_in_selectExprList741); @@ -2455,7 +2455,7 @@ }; // $ANTLR start "aliasedSelectExpr" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:165:1: aliasedSelectExpr : ^( AS se= selectExpr i= identifier ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:165:1: aliasedSelectExpr : ^( AS se= selectExpr i= identifier ) ; public HqlSqlWalker.aliasedSelectExpr_return aliasedSelectExpr() // throws RecognitionException [1] { HqlSqlWalker.aliasedSelectExpr_return retval = new HqlSqlWalker.aliasedSelectExpr_return(); @@ -2476,8 +2476,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:170:2: ( ^( AS se= selectExpr i= identifier ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:170:4: ^( AS se= selectExpr i= identifier ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:170:2: ( ^( AS se= selectExpr i= identifier ) ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:170:4: ^( AS se= selectExpr i= identifier ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2543,7 +2543,7 @@ }; // $ANTLR start "selectExpr" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:173:1: selectExpr : (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ); + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:173:1: selectExpr : (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ); public HqlSqlWalker.selectExpr_return selectExpr() // throws RecognitionException [1] { HqlSqlWalker.selectExpr_return retval = new HqlSqlWalker.selectExpr_return(); @@ -2582,7 +2582,7 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:174:2: (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:174:2: (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ) int alt19 = 10; switch ( input.LA(1) ) { @@ -2665,7 +2665,7 @@ switch (alt19) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:174:4: p= propertyRef + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:174:4: p= propertyRef { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2680,7 +2680,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:175:4: ^( ALL ar2= aliasRef ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:175:4: ^( ALL ar2= aliasRef ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2712,7 +2712,7 @@ } break; case 3 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:176:4: ^( OBJECT ar3= aliasRef ) + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:176:4: ^( OBJECT ar3= aliasRef ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2744,7 +2744,7 @@ } break; case 4 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:177:4: con= constructor + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:177:4: con= constructor { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2759,7 +2759,7 @@ } break; case 5 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:178:4: functionCall + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:178:4: functionCall { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2773,7 +2773,7 @@ } break; case 6 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:179:4: count + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:179:4: count { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2787,7 +2787,7 @@ } break; case 7 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:180:4: collectionFunction + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:180:4: collectionFunction { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2801,7 +2801,7 @@ } break; case 8 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:181:4: literal + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:181:4: literal { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2815,7 +2815,7 @@ } break; case 9 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:182:4: arithmeticExpr + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:182:4: arithmeticExpr { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2829,7 +2829,7 @@ } break; case 10 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:183:4: query + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:183:4: query { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2870,7 +2870,7 @@ }; // $ANTLR start "count" - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:186:1: count : ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ; + // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g:186:1: count : ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ; public HqlSqlWalker.count_return count() // throws RecognitionException [1] { HqlSqlWalker.count_return retval = new HqlSqlWalker.count_return(); @@ -2893,8 +2893,8 @@ try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql... [truncated message content] |
From: <fab...@us...> - 2009-07-05 16:55:23
|
Revision: 4583 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4583&view=rev Author: fabiomaulo Date: 2009-07-05 16:55:21 +0000 (Sun, 05 Jul 2009) Log Message: ----------- Merge r4582 (partial fix NH-1867) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs Modified: trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2009-07-05 16:52:07 UTC (rev 4582) +++ trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2009-07-05 16:55:21 UTC (rev 4583) @@ -65,7 +65,8 @@ { throw new ParserException("Invalid generic fully-qualified type name:" + type); } - string cardinalityString = type.Substring(genericTypeCardinalityIdx + 1, genericTypeArgsStartIdx - genericTypeCardinalityIdx - 1); + // the follow will fail with a generic class with more the 9 type-args (I would see that entity class) + string cardinalityString = type.Substring(genericTypeCardinalityIdx + 1, 1); int genericTypeCardinality = int.Parse(cardinalityString); // get the FullName of the non-generic type Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2009-07-05 16:52:07 UTC (rev 4582) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2009-07-05 16:55:21 UTC (rev 4583) @@ -265,5 +265,34 @@ var a = TypeNameParser.Parse(typeName); Assert.That(a.ToString(), Is.EqualTo(expected)); } + + private class A<T> + { + public class B { } + } + + private class Aa<T> + { + public class Bb<TX, TJ, TZ> + { + public class C { } + } + } + + [Test] + [Description("Parser multiple nested classes with a generic in the middle.")] + public void ParseNestedWithinGeneric() + { + // NH-1867 + CheckInput(typeof(A<int>.B).FullName, typeof(A<int>.B).FullName, null); + } + + [Test] + [Description("Parser multiple nested classes with a generics.")] + public void ComplexNestedWithGeneric() + { + CheckInput(typeof(Aa<int>.Bb<int, short, string>).FullName, typeof(Aa<int>.Bb<int, short, string>).FullName, null); + CheckInput(typeof(Aa<int>.Bb<int, short, string>.C).FullName, typeof(Aa<int>.Bb<int, short, string>.C).FullName, null); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |