You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2009-05-04 23:06:15
|
Revision: 4238 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4238&view=rev Author: fabiomaulo Date: 2009-05-04 23:06:06 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with subclass) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 23:03:21 UTC (rev 4237) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 23:06:06 UTC (rev 4238) @@ -32,7 +32,27 @@ } #endregion + [Test] + public void DeleteOnDiscriminatorSubclass() + { + var data = new TestData(this); + data.Prepare(); + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete PettingZoo").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + + count = s.CreateQuery("delete Zoo").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + [Test] public void DeleteOnJoinedSubclass() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 23:03:30
|
Revision: 4237 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4237&view=rev Author: fabiomaulo Date: 2009-05-04 23:03:21 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with joined table) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-04 22:45:13 UTC (rev 4236) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-04 23:03:21 UTC (rev 4237) @@ -280,7 +280,14 @@ public void SetFirstChild(IASTNode newChild) { - SetChild(0, newChild); + if (_children == null || _children.Count == 0) + { + AddChild(newChild); + } + else + { + _children[0] = newChild; + } } public void SetChild(int index, IASTNode newChild) Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:45:13 UTC (rev 4236) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 23:03:21 UTC (rev 4237) @@ -34,6 +34,30 @@ #endregion [Test] + public void DeleteOnJoinedSubclass() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Mammal where bodyWeight > 150").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + + count = s.CreateQuery("delete Mammal").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + + count = s.CreateQuery("delete SubMulti").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(0), "Incorrect deletion count on joined subclass"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteOnMappedJoin() { var data = new TestData(this); @@ -44,7 +68,7 @@ int count = s.CreateQuery("delete Joiner where joinedName = :joinedName") .SetString("joinedName", "joined-name").ExecuteUpdate(); - Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined class"); t.Commit(); s.Close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:45:31
|
Revision: 4236 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4236&view=rev Author: fabiomaulo Date: 2009-05-04 22:45:13 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with joined table) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:37:36 UTC (rev 4235) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:45:13 UTC (rev 4236) @@ -34,6 +34,25 @@ #endregion [Test] + public void DeleteOnMappedJoin() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Joiner where joinedName = :joinedName") + .SetString("joinedName", "joined-name").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteUnionSubclassAbstractRoot() { var data = new TestData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:37:46
|
Revision: 4235 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4235&view=rev Author: fabiomaulo Date: 2009-05-04 22:37:36 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with union-subclass) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:34:13 UTC (rev 4234) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:37:36 UTC (rev 4235) @@ -34,6 +34,29 @@ #endregion [Test] + public void DeleteUnionSubclassAbstractRoot() + { + var data = new TestData(this); + data.Prepare(); + + // These should reach out into *all* subclass tables... + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Vehicle where Owner = :owner") + .SetString("owner", "Steve").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "incorrect restricted update count"); + + count = s.CreateQuery("delete Vehicle").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(3), "incorrect update count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteUnionSubclassConcreteSubclass() { var data = new TestData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:34:21
|
Revision: 4234 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4234&view=rev Author: fabiomaulo Date: 2009-05-04 22:34:13 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with union-subclass) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:28:11 UTC (rev 4233) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:34:13 UTC (rev 4234) @@ -34,6 +34,29 @@ #endregion [Test] + public void DeleteUnionSubclassConcreteSubclass() + { + var data = new TestData(this); + data.Prepare(); + + // These should only affect the given table + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Truck where Owner = :owner") + .SetString("owner", "Steve") + .ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "incorrect restricted update count"); + + count = s.CreateQuery("delete Truck").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(2), "incorrect update count"); + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteUnionSubclassLeafSubclass() { var data = new TestData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:28:23
|
Revision: 4233 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4233&view=rev Author: fabiomaulo Date: 2009-05-04 22:28:11 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:19:42 UTC (rev 4232) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:28:11 UTC (rev 4233) @@ -34,6 +34,30 @@ #endregion [Test] + public void DeleteUnionSubclassLeafSubclass() + { + var data = new TestData(this); + data.Prepare(); + + // These should only affect the given table + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Car where Owner = :owner") + .SetString("owner", "Kirsten") + .ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "incorrect restricted update count"); + + count = s.CreateQuery("delete Car").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(0), "incorrect update count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteRestrictedOnManyToOne() { var data = new TestData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:19:46
|
Revision: 4232 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4232&view=rev Author: fabiomaulo Date: 2009-05-04 22:19:42 +0000 (Mon, 04 May 2009) Log Message: ----------- Simplified implementation Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 22:19:42 UTC (rev 4232) @@ -3,6 +3,7 @@ using System.Data; using System.Data.Common; using Antlr.Runtime; +using Antlr.Runtime.Tree; using log4net; using NHibernate.Engine; using NHibernate.Exceptions; @@ -21,17 +22,17 @@ private static readonly ILog log = LogManager.GetLogger(typeof(BasicExecutor)); private readonly SqlString sql; - public BasicExecutor(IStatement statement, ITokenStream tokenStream, IQueryable persister) + public BasicExecutor(IStatement statement, IQueryable persister) : base(statement, log) { this.persister = persister; try { - var generator = new HqlSqlGenerator(statement, tokenStream, Factory); - generator.Generate(); - - sql = generator.Sql; - Parameters = generator.CollectionParameters; + var gen = new SqlGenerator(Factory, new CommonTreeNodeStream(statement)); + gen.statement(); + sql = gen.GetSQL(); + gen.ParseErrorHandler.ThrowQueryException(); + Parameters = gen.GetCollectedParameters(); } catch (RecognitionException e) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 22:01:16 UTC (rev 4231) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 22:19:42 UTC (rev 4232) @@ -407,7 +407,7 @@ } else { - return new BasicExecutor(statement, _parser.Tokens, persister); + return new BasicExecutor(statement, persister); } } else if (walker.StatementType == HqlSqlWalker.UPDATE) @@ -423,7 +423,7 @@ } else { - return new BasicExecutor(statement, _parser.Tokens, persister); + return new BasicExecutor(statement, persister); } } else if (walker.StatementType == HqlSqlWalker.INSERT) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:01:27
|
Revision: 4231 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4231&view=rev Author: fabiomaulo Date: 2009-05-04 22:01:16 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (multi-table support) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -414,5 +414,12 @@ manager.flushingFromDtcTransaction = false; } } + + public IDbCommand CreateCommand() + { + var result = GetConnection().CreateCommand(); + Transaction.Enlist(result); + return result; + } } } Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -276,6 +276,21 @@ get { return true; } } + public override bool SupportsTemporaryTables + { + get { return true; } + } + + public override string GenerateTemporaryTableName(string baseTableName) + { + return "#" + baseTableName; + } + + public override bool DropTemporaryTableAfterUse() + { + return true; + } + /// <summary> /// /// </summary> Modified: trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -12,7 +12,10 @@ /// <summary> /// Perform the actual work to be done. /// </summary> - /// <param name="connection">The ADP cpnnection to use.</param> + /// <param name="connection">The ADP connection to use.</param> void DoWork(IDbConnection connection); + + // 2009-05-04 Another time we need a TransactionManager to manage isolated + // work for a given connection. } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Engine.Transaction; using NHibernate.Exceptions; @@ -30,7 +31,7 @@ { generatedValue = owner.DoWorkInCurrentTransaction(connection, null); } - catch (System.Data.OleDb.OleDbException sqle) + catch (DbException sqle) { throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, "could not get or update next value", null); } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -1,10 +1,18 @@ using System; +using System.Data; +using Antlr.Runtime.Tree; using NHibernate.Action; using NHibernate.Engine; +using NHibernate.Engine.Transaction; using NHibernate.Event; +using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using log4net; +using Antlr.Runtime; +using NHibernate.SqlTypes; +using NHibernate.Util; +using NHibernate.AdoNet.Util; namespace NHibernate.Hql.Ast.ANTLR.Exec { @@ -13,20 +21,27 @@ { private readonly ILog log; - protected AbstractStatementExecutor(HqlSqlWalker walker, ILog log) + protected AbstractStatementExecutor(IStatement statement, ILog log) { - Walker = walker; + Statement = statement; + Walker = statement.Walker; this.log = log; } protected HqlSqlWalker Walker { get; private set; } + protected IStatement Statement { get; private set; } - public abstract SqlString[] SqlStatements{get;} + public abstract SqlString[] SqlStatements { get; } public abstract int Execute(QueryParameters parameters, ISessionImplementor session); protected abstract IQueryable[] AffectedQueryables { get; } + protected ISessionFactoryImplementor Factory + { + get{return Walker.SessionFactoryHelper.Factory;} + } + protected virtual void CoordinateSharedCacheCleanup(ISessionImplementor session) { var action = new BulkOperationCleanupAction(session, AffectedQueryables); @@ -38,5 +53,248 @@ ((IEventSource)session).ActionQueue.AddAction(action); } } + + protected SqlString GenerateIdInsertSelect(IQueryable persister, string tableAlias, IASTNode whereClause) + { + var select = new SqlSelectBuilder(Factory); + SelectFragment selectFragment = new SelectFragment(Factory.Dialect) + .AddColumns(tableAlias, persister.IdentifierColumnNames, persister.IdentifierColumnNames); + select.SetSelectClause(selectFragment.ToFragmentString().Substring(2)); + + string rootTableName = persister.TableName; + SqlString fromJoinFragment = persister.FromJoinFragment(tableAlias, true, false); + SqlString whereJoinFragment = persister.WhereJoinFragment(tableAlias, true, false); + + select.SetFromClause(rootTableName + ' ' + tableAlias + fromJoinFragment); + + if (whereJoinFragment == null) + { + whereJoinFragment = SqlString.Empty; + } + else + { + whereJoinFragment = whereJoinFragment.Trim(); + if (whereJoinFragment.StartsWithCaseInsensitive("and ")) + { + whereJoinFragment = whereJoinFragment.Substring(4); + } + } + + SqlString userWhereClause = SqlString.Empty; + if (whereClause.ChildCount != 0) + { + // If a where clause was specified in the update/delete query, use it to limit the + // returned ids here... + try + { + var nodes = new CommonTreeNodeStream(whereClause); + var gen = new SqlGenerator(Factory, nodes); + gen.whereClause(); + userWhereClause = gen.GetSQL().Substring(7); + } + catch (RecognitionException e) + { + throw new HibernateException("Unable to generate id select for DML operation", e); + } + if (whereJoinFragment.Length > 0) + { + whereJoinFragment.Append(" and "); + } + } + + select.SetWhereClause(whereJoinFragment + userWhereClause); + + var insert = new InsertSelect(); + if (Factory.Settings.IsCommentsEnabled) + { + insert.SetComment("insert-select for " + persister.EntityName + " ids"); + } + insert.SetTableName(persister.TemporaryIdTableName); + insert.SetSelect(select); + return insert.ToSqlString(); + } + + protected string GenerateIdSubselect(IQueryable persister) + { + return "select " + StringHelper.Join(", ", persister.IdentifierColumnNames) + " from " + persister.TemporaryIdTableName; + } + + protected virtual void CreateTemporaryTableIfNecessary(IQueryable persister, ISessionImplementor session) + { + // Don't really know all the codes required to adequately decipher returned ADO exceptions here. + // simply allow the failure to be eaten and the subsequent insert-selects/deletes should fail + IIsolatedWork work = new TmpIdTableCreationIsolatedWork(persister, log, session); + if (ShouldIsolateTemporaryTableDDL()) + { + if (Factory.Settings.IsDataDefinitionInTransactionSupported) + { + Isolater.DoIsolatedWork(work, session); + } + else + { + Isolater.DoNonTransactedWork(work, session); + } + } + else + { + work.DoWork(session.ConnectionManager.GetConnection()); + session.ConnectionManager.AfterStatement(); + } + } + + protected virtual bool ShouldIsolateTemporaryTableDDL() + { + bool? dialectVote = Factory.Dialect.PerformTemporaryTableDDLInIsolation(); + if (dialectVote.HasValue) + { + return dialectVote.Value; + } + else + { + return Factory.Settings.IsDataDefinitionImplicitCommit; + } + } + + protected virtual void DropTemporaryTableIfNecessary(IQueryable persister, ISessionImplementor session) + { + if (Factory.Dialect.DropTemporaryTableAfterUse()) + { + IIsolatedWork work = new TmpIdTableDropIsolatedWork(persister, log, session); + + if (ShouldIsolateTemporaryTableDDL()) + { + if (Factory.Settings.IsDataDefinitionInTransactionSupported) + { + Isolater.DoIsolatedWork(work, session); + } + else + { + Isolater.DoNonTransactedWork(work, session); + } + } + else + { + work.DoWork(session.ConnectionManager.GetConnection()); + session.ConnectionManager.AfterStatement(); + } + } + else + { + // at the very least cleanup the data :) + IDbCommand ps = null; + try + { + var commandText = new SqlString("delete from " + persister.TemporaryIdTableName); + ps = session.Batcher.PrepareCommand(CommandType.Text, commandText, new SqlType[0]); + ps.ExecuteNonQuery(); + } + catch (Exception t) + { + log.Warn("unable to cleanup temporary id table after use [" + t + "]"); + } + finally + { + if (ps != null) + { + try + { + session.Batcher.CloseCommand(ps, null); + } + catch (Exception) + { + // ignore + } + } + } + } + } + + private class TmpIdTableCreationIsolatedWork : IIsolatedWork + { + private readonly IQueryable persister; + private readonly ILog log; + private readonly ISessionImplementor session; + + public TmpIdTableCreationIsolatedWork(IQueryable persister, ILog log, ISessionImplementor session) + { + this.persister = persister; + this.log = log; + this.session = session; + } + + public void DoWork(IDbConnection connection) + { + IDbCommand stmnt = null; + try + { + stmnt = session.ConnectionManager.CreateCommand(); + stmnt.CommandText = persister.TemporaryIdTableDDL; + stmnt.ExecuteNonQuery(); + session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); + } + catch (Exception t) + { + log.Debug("unable to create temporary id table [" + t.Message + "]"); + } + finally + { + if (stmnt != null) + { + try + { + stmnt.Dispose(); + } + catch (Exception) + { + // ignore + } + } + } + } + } + + private class TmpIdTableDropIsolatedWork : IIsolatedWork + { + public TmpIdTableDropIsolatedWork(IQueryable persister, ILog log, ISessionImplementor session) + { + this.persister = persister; + this.log = log; + this.session = session; + } + + private readonly IQueryable persister; + private readonly ILog log; + private readonly ISessionImplementor session; + + public void DoWork(IDbConnection connection) + { + IDbCommand stmnt = null; + try + { + stmnt = session.ConnectionManager.CreateCommand(); + stmnt.CommandText = "drop table " + persister.TemporaryIdTableName; + stmnt.ExecuteNonQuery(); + session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); + } + catch (Exception t) + { + log.Warn("unable to drop temporary id table after use [" + t.Message + "]"); + } + finally + { + if (stmnt != null) + { + try + { + stmnt.Dispose(); + } + catch (Exception) + { + // ignore + } + } + } + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -18,11 +18,11 @@ public class BasicExecutor : AbstractStatementExecutor { private readonly IQueryable persister; - private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); + private static readonly ILog log = LogManager.GetLogger(typeof(BasicExecutor)); private readonly SqlString sql; public BasicExecutor(IStatement statement, ITokenStream tokenStream, IQueryable persister) - : base(statement.Walker, log) + : base(statement, log) { this.persister = persister; try @@ -41,14 +41,6 @@ protected IList<IParameterSpecification> Parameters{get;private set;} - protected ISessionFactoryImplementor Factory - { - get - { - return Walker.SessionFactoryHelper.Factory; - } - } - public override SqlString[] SqlStatements { get { return new[] {sql}; } @@ -72,7 +64,8 @@ } st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); IEnumerator<IParameterSpecification> paramSpecifications = Parameters.GetEnumerator(); - int pos = 1; + // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) + int pos = 0; while (paramSpecifications.MoveNext()) { var paramSpec = paramSpecifications.Current; Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; +using NHibernate.Util; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public class MultiTableDeleteExecutor : AbstractStatementExecutor + { + private static readonly ILog log = LogManager.GetLogger(typeof(MultiTableDeleteExecutor)); + private readonly IQueryable persister; + private readonly SqlString idInsertSelect; + private readonly SqlString[] deletes; + + public MultiTableDeleteExecutor(IStatement statement) + : base(statement, log) + { + if (!Factory.Dialect.SupportsTemporaryTables) + { + throw new HibernateException("cannot perform multi-table deletes using dialect not supporting temp tables"); + } + + var deleteStatement = (DeleteStatement) statement; + + FromElement fromElement = deleteStatement.FromClause.GetFromElement(); + string bulkTargetAlias = fromElement.TableAlias; + persister = fromElement.Queryable; + + idInsertSelect = GenerateIdInsertSelect(persister, bulkTargetAlias, deleteStatement.WhereClause); + log.Debug("Generated ID-INSERT-SELECT SQL (multi-table delete) : " + idInsertSelect); + + string[] tableNames = persister.ConstraintOrderedTableNameClosure; + string[][] columnNames = persister.ContraintOrderedTableKeyColumnClosure; + string idSubselect = GenerateIdSubselect(persister); + + deletes = new SqlString[tableNames.Length]; + for (int i = tableNames.Length - 1; i >= 0; i--) + { + // TODO : an optimization here would be to consider cascade deletes and not gen those delete statements; + // the difficulty is the ordering of the tables here vs the cascade attributes on the persisters -> + // the table info gotten here should really be self-contained (i.e., a class representation + // defining all the needed attributes), then we could then get an array of those + SqlDeleteBuilder delete = new SqlDeleteBuilder(Factory.Dialect, Factory) + .SetTableName(tableNames[i]) + .SetWhere("(" + StringHelper.Join(", ", columnNames[i]) + ") IN (" + idSubselect + ")"); + if (Factory.Settings.IsCommentsEnabled) + { + delete.SetComment("bulk delete"); + } + + deletes[i] = delete.ToSqlString(); + } + } + + public override SqlString[] SqlStatements + { + get { return deletes; } + } + + public override int Execute(QueryParameters parameters, ISessionImplementor session) + { + CoordinateSharedCacheCleanup(session); + + CreateTemporaryTableIfNecessary(persister, session); + + try + { + // First, save off the pertinent ids, saving the number of pertinent ids for return + IDbCommand ps = null; + int resultCount; + try + { + try + { + var parameterTypes = new List<SqlType>(Walker.Parameters.Count); + foreach (var parameterSpecification in Walker.Parameters) + { + parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); + } + + ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, parameterTypes.ToArray()); + IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) + int pos = 0; + while (paramSpecifications.MoveNext()) + { + var paramSpec = paramSpecifications.Current; + pos += paramSpec.Bind(ps, parameters, session, pos); + } + resultCount = session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not insert/select ids for bulk delete", idInsertSelect); + } + + // Start performing the deletes + for (int i = 0; i < deletes.Length; i++) + { + try + { + try + { + ps = session.Batcher.PrepareCommand(CommandType.Text, deletes[i], new SqlType[0]); + session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "error performing bulk delete", deletes[i]); + } + } + + return resultCount; + } + finally + { + DropTemporaryTableIfNecessary(persister, session); + } + } + + protected override IQueryable[] AffectedQueryables + { + get { return new[] { persister }; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -403,8 +403,7 @@ IQueryable persister = fromElement.Queryable; if (persister.IsMultiTable) { - throw new NotSupportedException(); - //return new MultiTableDeleteExecutor(walker); + return new MultiTableDeleteExecutor(statement); } else { @@ -420,8 +419,7 @@ // even here, if only properties mapped to the "base table" are referenced // in the set and where clauses, this could be handled by the BasicDelegate. // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate - throw new NotSupportedException(); - //return new MultiTableUpdateExecutor(walker); + return new MultiTableDeleteExecutor(statement); } else { Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-04 22:01:16 UTC (rev 4231) @@ -483,6 +483,7 @@ <Compile Include="Hql\Ast\ANTLR\Exec\AbstractStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\BasicExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\MultiTableDeleteExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs" /> @@ -584,6 +585,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\JoinProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> + <Compile Include="SqlCommand\InsertSelect.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> Added: trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -0,0 +1,79 @@ +using System.Collections.Generic; +using log4net; +using NHibernate.Engine; + +namespace NHibernate.SqlCommand +{ + public class InsertSelect : ISqlStringBuilder + { + private static readonly ILog log = LogManager.GetLogger(typeof(InsertSelect)); + + private readonly ISessionFactoryImplementor factory; + private string tableName; + private string comment; + private readonly List<string> columnNames = new List<string>(); + private SqlSelectBuilder select; + + public virtual InsertSelect SetTableName(string tableName) + { + this.tableName = tableName; + return this; + } + + public virtual InsertSelect SetComment(string comment) + { + this.comment = comment; + return this; + } + + public virtual InsertSelect AddColumn(string columnName) + { + columnNames.Add(columnName); + return this; + } + + public virtual InsertSelect AddColumns(string[] columnNames) + { + this.columnNames.AddRange(columnNames); + return this; + } + + public virtual InsertSelect SetSelect(SqlSelectBuilder select) + { + this.select = select; + return this; + } + + public SqlString ToSqlString() + { + if (tableName == null) + throw new HibernateException("no table name defined for insert-select"); + if (select == null) + throw new HibernateException("no select defined for insert-select"); + + var buf = new SqlStringBuilder(columnNames.Count + 4); + if (comment != null) + { + buf.Add("/* " + comment + " */ "); + } + buf.Add("insert into ").Add(tableName); + if (!(columnNames.Count == 0)) + { + buf.Add(" ("); + bool commaNeeded= false; + foreach (var columnName in columnNames) + { + if(commaNeeded) + { + buf.Add(", "); + } + buf.Add(columnName); + commaNeeded = true; + } + buf.Add(")"); + } + buf.Add(" ").Add(select.ToStatementString()); + return buf.ToSqlString(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -15,7 +15,7 @@ private static readonly ILog log = LogManager.GetLogger(typeof(SqlDeleteBuilder)); private string tableName; - private readonly List<SqlString> whereStrings = new List<SqlString>(); + private List<SqlString> whereStrings = new List<SqlString>(); private readonly List<SqlType> parameterTypes = new List<SqlType>(); private string comment; @@ -81,7 +81,6 @@ return this; } - public SqlDeleteBuilder AddWhereFragment(string columnName, SqlType type, string op) { if (!string.IsNullOrEmpty(columnName)) @@ -91,6 +90,7 @@ } return this; } + /// <summary> /// Adds a string to the WhereFragement /// </summary> @@ -104,6 +104,15 @@ return this; } + public virtual SqlDeleteBuilder SetWhere(string whereSql) + { + if (StringHelper.IsNotEmpty(whereSql)) + { + whereStrings = new List<SqlString>(new[]{ new SqlString(whereSql)}); + } + return this; + } + #region ISqlStringBuilder Members public SqlString ToSqlString() Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -207,7 +207,9 @@ // plus the number of parts in outerJoinsAfterWhere SqlString. // 1 = the whereClause // 2 = the "ORDER BY" and orderByClause - int initialCapacity = 4 + outerJoinsAfterFrom.Count + 1 + outerJoinsAfterWhere.Count + 1 + 2; + var joinAfterFrom = outerJoinsAfterFrom != null ? outerJoinsAfterFrom.Count : 0; + var joinAfterWhere = outerJoinsAfterWhere != null ? outerJoinsAfterWhere.Count : 0; + int initialCapacity = 4 + joinAfterFrom + 1 + joinAfterWhere + 1 + 2; if (!string.IsNullOrEmpty(comment)) initialCapacity++; @@ -218,9 +220,13 @@ sqlBuilder.Add("SELECT ") .Add(selectClause) .Add(" FROM ") - .Add(fromClause) - .Add(outerJoinsAfterFrom); + .Add(fromClause); + if (StringHelper.IsNotEmpty(outerJoinsAfterFrom)) + { + sqlBuilder.Add(outerJoinsAfterFrom); + } + if (StringHelper.IsNotEmpty(whereClause) || StringHelper.IsNotEmpty(outerJoinsAfterWhere)) { sqlBuilder.Add(" WHERE "); Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -60,5 +60,15 @@ get { return serialNumber; } set { serialNumber = value; } } + + public virtual void AddOffspring(Animal offSpring) + { + if (offspring == null) + { + offspring = new HashedSet(); + } + + offspring.Add(offSpring); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -33,7 +33,7 @@ #endregion - [Test, Ignore("Not supported")] + [Test] public void DeleteRestrictedOnManyToOne() { var data = new TestData(this); @@ -95,12 +95,12 @@ Frog = new Animal { BodyWeight = 34, Description = "Frog" }; Polliwog.Father = Frog; - Frog.Offspring.Add(Polliwog); + Frog.AddOffspring(Polliwog); Butterfly = new Animal { BodyWeight = 9, Description = "Butterfly" }; Catepillar.Mother = Butterfly; - Butterfly.Offspring.Add(Catepillar); + Butterfly.AddOffspring(Catepillar); s.Save(Frog); s.Save(Polliwog); Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-04 22:01:16 UTC (rev 4231) @@ -6,7 +6,7 @@ <!-- Vehicle represents an abstract root of a union-subclass hierarchy --> <class name="Vehicle" abstract="true"> <id name="id" access="field" type="long"> - <generator class="increment"/> + <generator class="hilo"/> </id> <property name="Vin" type="string"/> <property name="Owner" type="string"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 14:22:19
|
Revision: 4230 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4230&view=rev Author: fabiomaulo Date: 2009-05-04 13:34:20 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -1,5 +1,8 @@ using System; +using NHibernate.Action; using NHibernate.Engine; +using NHibernate.Event; +using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using log4net; @@ -21,5 +24,19 @@ public abstract SqlString[] SqlStatements{get;} public abstract int Execute(QueryParameters parameters, ISessionImplementor session); + + protected abstract IQueryable[] AffectedQueryables { get; } + + protected virtual void CoordinateSharedCacheCleanup(ISessionImplementor session) + { + var action = new BulkOperationCleanupAction(session, AffectedQueryables); + + action.Init(); + + if (session.IsEventSource) + { + ((IEventSource)session).ActionQueue.AddAction(action); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -56,7 +56,7 @@ public override int Execute(QueryParameters parameters, ISessionImplementor session) { - //CoordinateSharedCacheCleanup(session); + CoordinateSharedCacheCleanup(session); IDbCommand st = null; RowSelection selection = parameters.RowSelection; @@ -101,5 +101,10 @@ "could not execute update query", sql); } } + + protected override IQueryable[] AffectedQueryables + { + get { return new[] { persister }; } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -162,6 +162,6 @@ txn.Commit(); s.Close(); } - } + } } } \ 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: <fab...@us...> - 2009-05-04 05:09:46
|
Revision: 4229 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4229&view=rev Author: fabiomaulo Date: 2009-05-04 05:09:41 +0000 (Mon, 04 May 2009) Log Message: ----------- Some more tests about delete Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-03 22:24:46 UTC (rev 4228) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-04 05:09:41 UTC (rev 4229) @@ -19,14 +19,17 @@ using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { - s.CreateQuery("delete from SimpleClass").ExecuteUpdate(); + Assert.That(s.CreateQuery("delete from SimpleClass where Description = 'simple2'").ExecuteUpdate(), + Is.EqualTo(1)); tx.Commit(); } using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) { - var l = s.CreateQuery("from SimpleClass").List(); - Assert.That(l.Count, Is.EqualTo(0)); + Assert.That(s.CreateQuery("delete from SimpleClass").ExecuteUpdate(), + Is.EqualTo(1)); + tx.Commit(); } } } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-03 22:24:46 UTC (rev 4228) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 05:09:41 UTC (rev 4229) @@ -6,6 +6,11 @@ [TestFixture] public class BulkManipulation: BaseFixture { + public ISession OpenNewSession() + { + return OpenSession(); + } + #region Non-exists [Test] @@ -27,5 +32,136 @@ } #endregion + + [Test, Ignore("Not supported")] + public void DeleteRestrictedOnManyToOne() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Animal where mother = :mother") + .SetEntity("mother", data.Butterfly) + .ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1)); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] + public void DeleteSyntaxWithCompositeId() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + s.CreateQuery("delete EntityWithCrazyCompositeKey where Id.Id = 1 and Id.OtherId = 2").ExecuteUpdate(); + s.CreateQuery("delete from EntityWithCrazyCompositeKey where Id.Id = 1 and Id.OtherId = 2").ExecuteUpdate(); + s.CreateQuery("delete from EntityWithCrazyCompositeKey e where e.Id.Id = 1 and e.Id.OtherId = 2").ExecuteUpdate(); + + t.Commit(); + s.Close(); + } + + private class TestData + { + private readonly BulkManipulation tc; + public Animal Polliwog; + public Animal Catepillar; + public Animal Frog; + public Animal Butterfly; + + public Zoo Zoo; + public Zoo PettingZoo; + + public TestData(BulkManipulation tc) + { + this.tc = tc; + } + + public void Prepare() + { + ISession s = tc.OpenNewSession(); + ITransaction txn = s.BeginTransaction(); + + Polliwog = new Animal { BodyWeight = 12, Description = "Polliwog" }; + + Catepillar = new Animal { BodyWeight = 10, Description = "Catepillar" }; + + Frog = new Animal { BodyWeight = 34, Description = "Frog" }; + + Polliwog.Father = Frog; + Frog.Offspring.Add(Polliwog); + + Butterfly = new Animal { BodyWeight = 9, Description = "Butterfly" }; + + Catepillar.Mother = Butterfly; + Butterfly.Offspring.Add(Catepillar); + + s.Save(Frog); + s.Save(Polliwog); + s.Save(Butterfly); + s.Save(Catepillar); + + var dog = new Dog { BodyWeight = 200, Description = "dog" }; + s.Save(dog); + + var cat = new Cat { BodyWeight = 100, Description = "cat" }; + s.Save(cat); + + Zoo = new Zoo { Name = "Zoo" }; + var add = new Address { City = "MEL", Country = "AU", Street = "Main st", PostalCode = "3000" }; + Zoo.Address = add; + + PettingZoo = new PettingZoo { Name = "Petting Zoo" }; + var addr = new Address { City = "Sydney", Country = "AU", Street = "High st", PostalCode = "2000" }; + PettingZoo.Address = addr; + + s.Save(Zoo); + s.Save(PettingZoo); + + var joiner = new Joiner { JoinedName = "joined-name", Name = "name" }; + s.Save(joiner); + + var car = new Car { Vin = "123c", Owner = "Kirsten" }; + s.Save(car); + + var truck = new Truck { Vin = "123t", Owner = "Steve" }; + s.Save(truck); + + var suv = new SUV { Vin = "123s", Owner = "Joe" }; + s.Save(suv); + + var pickup = new Pickup { Vin = "123p", Owner = "Cecelia" }; + s.Save(pickup); + + var b = new BooleanLiteralEntity(); + s.Save(b); + + txn.Commit(); + s.Close(); + } + + public void Cleanup() + { + ISession s = tc.OpenNewSession(); + ITransaction txn = s.BeginTransaction(); + + // workaround awesome HSQLDB "feature" + s.CreateQuery("delete from Animal where mother is not null or father is not null").ExecuteUpdate(); + s.CreateQuery("delete from Animal").ExecuteUpdate(); + s.CreateQuery("delete from Zoo").ExecuteUpdate(); + s.CreateQuery("delete from Joiner").ExecuteUpdate(); + s.CreateQuery("delete from Vehicle").ExecuteUpdate(); + s.CreateQuery("delete from BooleanLiteralEntity").ExecuteUpdate(); + + txn.Commit(); + s.Close(); + } + } } } \ 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: <fab...@us...> - 2009-05-03 22:24:56
|
Revision: 4228 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4228&view=rev Author: fabiomaulo Date: 2009-05-03 22:24:46 +0000 (Sun, 03 May 2009) Log Message: ----------- Port of classes and mappings for AST tests (at least for BulkUpdates) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Address.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Classification.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/CrazyCompositeKey.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/DomesticAnimal.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Human.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/IntegerVersioned.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Joiner.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneKeyEntity.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Mammal.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Name.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Reptile.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleAssociatedEntity.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/StateProvince.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/TimestampVersioned.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/User.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicles.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Zoo.cs Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Address.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Address.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Address.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,41 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class Address + { + private string street; + private string city; + private string postalCode; + private string country; + private StateProvince stateProvince; + + public string Street + { + get { return street; } + set { street = value; } + } + + public string City + { + get { return city; } + set { city = value; } + } + + public string PostalCode + { + get { return postalCode; } + set { postalCode = value; } + } + + public string Country + { + get { return country; } + set { country = value; } + } + + public StateProvince StateProvince + { + get { return stateProvince; } + set { stateProvince = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,64 @@ +using Iesi.Collections; + +namespace NHibernate.Test.HQL.Ast +{ + public class Animal + { + private long id; + private float bodyWeight; + private ISet offspring; + private Animal mother; + private Animal father; + private string description; + private Zoo zoo; + private string serialNumber; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual float BodyWeight + { + get { return bodyWeight; } + set { bodyWeight = value; } + } + + public virtual ISet Offspring + { + get { return offspring; } + set { offspring = value; } + } + + public virtual Animal Mother + { + get { return mother; } + set { mother = value; } + } + + public virtual Animal Father + { + get { return father; } + set { father = value; } + } + + public virtual string Description + { + get { return description; } + set { description = value; } + } + + public virtual Zoo Zoo + { + get { return zoo; } + set { zoo = value; } + } + + public virtual string SerialNumber + { + get { return serialNumber; } + set { serialNumber = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -3,148 +3,148 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.HQL.Ast" default-access="field"> - - <class name="Animal"> - <id name="id"> - <generator class="native"/> - </id> - <property name="description"/> - <property name="bodyWeight" column="body_weight"/> - <many-to-one name="mother" column="mother_id"/> - <many-to-one name="father" column="father_id"/> - <many-to-one name="zoo" column="zoo_id"/> - <property name="serialNumber"/> - <set name="offspring" order-by="father_id"> - <key column="mother_id"/> - <one-to-many class="Animal"/> - </set> - <joined-subclass name="Reptile"> - <key column="animal"/> - <property name="bodyTemperature"/> - <joined-subclass name="Lizard"> - <key column="reptile"/> - </joined-subclass> - </joined-subclass> - <joined-subclass name="Mammal"> - <key column="animal"/> - <property name="pregnant"/> - <property name="birthdate" type="date"/> - <joined-subclass name="DomesticAnimal"> - <key column="mammal"/> - <many-to-one name="owner"/> - <joined-subclass name="Cat"> - <key column="mammal"/> - </joined-subclass> - <joined-subclass name="Dog"> - <key column="mammal"/> - </joined-subclass> - </joined-subclass> - <joined-subclass name="Human"> - <key column="mammal"/> - <component name="name"> - <property name="first" column="name_first"/> - <property name="initial" column="name_initial"/> - <property name="last" column="name_last"/> - </component> - <property name="nickName"/> - <property name="height"/> - - <property name="intValue"/> - <property name="floatValue"/> - <property name="bigDecimalValue"/> - <property name="bigIntegerValue"/> - - <bag name="friends"> - <key column="human1"/> - <many-to-many column="human2" class="Human"/> - </bag> - <map name="family"> - <key column="human1"/> - <map-key column="relationship" type="string"/> - <many-to-many column="human2" class="Human"/> - </map> - <bag name="pets" inverse="true"> - <key column="owner"/> - <one-to-many class="DomesticAnimal"/> - </bag> - <set name="nickNames" lazy="false" table="human_nick_names" sort="natural"> - <key column="human"/> - <element column="nick_name" type="string" not-null="true"/> - </set> - <map name="addresses" table="addresses"> - <key column="human"/> - <map-key type="string" column="type"/> - <composite-element class="Address"> - <property name="street"/> - <property name="city"/> - <property name="postalCode"/> - <property name="country"/> - <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> - </composite-element> - </map> - </joined-subclass> - </joined-subclass> - </class> - - <class name="User" table="`User`"> - <id name="id"> - <generator class="foreign"> - <param name="property">human</param> - </generator> - </id> - <property name="userName"/> - <one-to-one name="human" constrained="true"/> - <list name="permissions"> - <key column="userId"/> - <list-index column="permissionId"/> - <element type="string" column="permissionName"/> - </list> - </class> - - <class name="Zoo" discriminator-value="Z"> - <id name="id"> - <generator class="native"/> - </id> - <discriminator column="zooType" type="character"/> - <property name="name" type="string"/> - <property name="classification" type="org.hibernate.test.hql.ClassificationType"/> - <map name="mammals"> - <key column="mammalZoo_id"/> - <index type="string" column="name"/> - <one-to-many class="Mammal"/> - </map> - <map name="animals" inverse="true"> - <key column="zoo_id"/> - <index type="string" column="serialNumber"/> - <one-to-many class="Animal"/> - </map> - <component name="address" class="Address"> - <property name="street"/> - <property name="city"/> - <property name="postalCode"/> - <property name="country"/> - <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> - </component> - <subclass name="PettingZoo" discriminator-value="P"/> - </class> - - <class name="StateProvince"> - <id name="id"> - <generator class="native"/> - </id> - <property name="name"/> - <property name="isoCode"/> - </class> - - <class name="Joiner"> - <id name="id"> - <generator class="native"/> - </id> - <property name="name"/> - <join table="JOINED"> - <key column="ID"/> - <property name="joinedName"/> - </join> - </class> - + + <class name="Animal"> + <id name="id"> + <generator class="native"/> + </id> + <property name="description"/> + <property name="bodyWeight" column="body_weight"/> + <many-to-one name="mother" column="mother_id"/> + <many-to-one name="father" column="father_id"/> + <many-to-one name="zoo" column="zoo_id"/> + <property name="serialNumber"/> + <set name="offspring" order-by="father_id"> + <key column="mother_id"/> + <one-to-many class="Animal"/> + </set> + <joined-subclass name="Reptile"> + <key column="animal"/> + <property name="bodyTemperature"/> + <joined-subclass name="Lizard"> + <key column="reptile"/> + </joined-subclass> + </joined-subclass> + <joined-subclass name="Mammal"> + <key column="animal"/> + <property name="pregnant"/> + <property name="birthdate" type="date"/> + <joined-subclass name="DomesticAnimal"> + <key column="mammal"/> + <many-to-one name="owner"/> + <joined-subclass name="Cat"> + <key column="mammal"/> + </joined-subclass> + <joined-subclass name="Dog"> + <key column="mammal"/> + </joined-subclass> + </joined-subclass> + <joined-subclass name="Human"> + <key column="mammal"/> + <component name="name"> + <property name="first" column="name_first"/> + <property name="initial" column="name_initial"/> + <property name="last" column="name_last"/> + </component> + <property name="nickName"/> + <property name="height"/> + + <property name="intValue"/> + <property name="floatValue"/> + <property name="bigDecimalValue"/> + <property name="bigIntegerValue"/> + + <bag name="friends"> + <key column="human1"/> + <many-to-many column="human2" class="Human"/> + </bag> + <map name="family"> + <key column="human1"/> + <map-key column="relationship" type="string"/> + <many-to-many column="human2" class="Human"/> + </map> + <bag name="pets" inverse="true"> + <key column="owner"/> + <one-to-many class="DomesticAnimal"/> + </bag> + <set name="nickNames" lazy="false" table="human_nick_names" sort="natural"> + <key column="human"/> + <element column="nick_name" type="string" not-null="true"/> + </set> + <map name="addresses" table="addresses"> + <key column="human"/> + <map-key type="string" column="type"/> + <composite-element class="Address"> + <property name="street"/> + <property name="city"/> + <property name="postalCode"/> + <property name="country"/> + <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> + </composite-element> + </map> + </joined-subclass> + </joined-subclass> + </class> + + <class name="User" table="`User`"> + <id name="id"> + <generator class="foreign"> + <param name="property">human</param> + </generator> + </id> + <property name="userName"/> + <one-to-one name="human" constrained="true"/> + <list name="permissions"> + <key column="userId"/> + <list-index column="permissionId"/> + <element type="string" column="permissionName"/> + </list> + </class> + + <class name="Zoo" discriminator-value="Z"> + <id name="id"> + <generator class="native"/> + </id> + <discriminator column="zooType" type="character"/> + <property name="name" type="string"/> + <property name="classification"/> + <map name="mammals"> + <key column="mammalZoo_id"/> + <index type="string" column="name"/> + <one-to-many class="Mammal"/> + </map> + <map name="animals" inverse="true"> + <key column="zoo_id"/> + <index type="string" column="serialNumber"/> + <one-to-many class="Animal"/> + </map> + <component name="address" class="Address"> + <property name="street"/> + <property name="city"/> + <property name="postalCode"/> + <property name="country"/> + <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> + </component> + <subclass name="PettingZoo" discriminator-value="P"/> + </class> + + <class name="StateProvince"> + <id name="id"> + <generator class="native"/> + </id> + <property name="name"/> + <property name="isoCode"/> + </class> + + <class name="Joiner"> + <id name="id"> + <generator class="native"/> + </id> + <property name="name"/> + <join table="JOINED"> + <key column="ID"/> + <property name="joinedName"/> + </join> + </class> + </hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,10 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class BooleanLiteralEntity + { + public virtual long Id { get; set; } + public virtual bool YesNoBoolean { get; set; } + public virtual bool TrueFalseBoolean { get; set; } + public virtual bool ZeroOneBoolean { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -1,15 +1,31 @@ +using NUnit.Framework; +using NHibernate.Hql.Ast.ANTLR; + namespace NHibernate.Test.HQL.Ast { + [TestFixture] public class BulkManipulation: BaseFixture { - // "hql/Animal.hbm.xml", - // "hql/Vehicle.hbm.xml", - // "hql/KeyManyToOneEntity.hbm.xml", - // "hql/Versions.hbm.xml", - //"hql/FooBarCopy.hbm.xml", - //"legacy/Multi.hbm.xml", - //"hql/EntityWithCrazyCompositeKey.hbm.xml", - //"hql/SimpleEntityWithAssociation.hbm.xml", - //"hql/BooleanLiteralEntity.hbm.xml" + #region Non-exists + + [Test] + public void DeleteNonExistentEntity() + { + using (ISession s = OpenSession()) + { + Assert.Throws<QuerySyntaxException>(() => s.CreateQuery("delete NonExistentEntity").ExecuteUpdate()); + } + } + + [Test] + public void UpdateNonExistentEntity() + { + using (ISession s = OpenSession()) + { + Assert.Throws<QuerySyntaxException>(() => s.CreateQuery("update NonExistentEntity e set e.someProp = ?").ExecuteUpdate()); + } + } + + #endregion } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Classification.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Classification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Classification.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.HQL.Ast +{ + public enum Classification + { + Cool = 0, + Lame = 1 + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/CrazyCompositeKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/CrazyCompositeKey.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/CrazyCompositeKey.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,51 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class CrazyCompositeKey + { + private long id; + private long otherId; + private int? requestedHash; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual long OtherId + { + get { return otherId; } + set { otherId = value; } + } + + public override bool Equals(object obj) + { + return Equals(obj as CrazyCompositeKey); + } + + public virtual bool Equals(CrazyCompositeKey other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return other.id == id && other.otherId == otherId; + } + + public override int GetHashCode() + { + if (!requestedHash.HasValue) + { + unchecked + { + requestedHash = (id.GetHashCode() * 397) ^ otherId.GetHashCode(); + } + } + return requestedHash.Value; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/DomesticAnimal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/DomesticAnimal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/DomesticAnimal.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,16 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class DomesticAnimal: Mammal + { + private Human owner; + + public virtual Human Owner + { + get { return owner; } + set { owner = value; } + } + } + + public class Cat : DomesticAnimal { } + public class Dog : DomesticAnimal { } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,20 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class EntityWithCrazyCompositeKey + { + private CrazyCompositeKey id; + private string name; + + public virtual CrazyCompositeKey Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -3,12 +3,12 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.HQL.Ast"> - <class name="EntityWithCrazyCompositeKey"> - <composite-id name="Id" class="CrazyCompositeKey"> - <key-property name="Id" column="id"/> - <key-property name="OtherId" column="other_id"/> - </composite-id> - <property name="Name"/> - </class> - + <class name="EntityWithCrazyCompositeKey"> + <composite-id name="Id" class="CrazyCompositeKey"> + <key-property name="Id" column="id"/> + <key-property name="OtherId" column="other_id"/> + </composite-id> + <property name="Name"/> + </class> + </hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -1,137 +1,140 @@ <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" - assembly="NHibernate.Test" - namespace="NHibernate.Test.HQL.Ast" - default-lazy="false"> - - <!-- a slightly modified copy of FooBar.hbm.xml from the legacy test package --> - - <class - name="Foo" - table="`foos`" - proxy="FooProxy" - discriminator-value="F" - batch-size="4" - dynamic-insert="true" - dynamic-update="true" - select-before-update="true"> - - <id name="key" type="string"> - <column name="`foo_idcolumnname123`" length="36"/> - <generator class="uuid.hex"> - <param name="seperator">:</param> - </generator> - </id> - - <discriminator column="`foo_subclass_1234`" type="character" force="true"/> - <version name="version"/> - - <many-to-one name="foo" class="Foo"> - <column name="foo" length="36" index="fbmtoidx"/> - </many-to-one> - - <property name="long"> - <column name="long_" index="fbmtoidx" unique-key="abc" not-null="true"/> - </property> - <property name="integer"> - <column name="`integer__`" unique-key="abc" not-null="true"/> - </property> - <property name="float"> - <column name="float_" unique-key="abc" not-null="true" check="float_ > 0.0"/> - </property> - <property name="x"/> - <property name="double" column="double_"/> - - <primitive-array name="bytes" table="foobytes"> - <key column="id"/> - <index column="i"/> - <element column="byte_" type="byte"/> - </primitive-array> - - <property name="date" type="date" column="date_"/> - <property name="timestamp" type="timestamp" column="timestamp_"/> - <property name="boolean" column="boolean_"/> - <property name="bool" column="bool_"/> - <property name="null" column="null_"/> - <property name="short" column="short_"/> - <property name="char" column="char_"/> - <property name="zero" column="zero_"/> - <property name="int" column="int_"/> - <property name="string"> - <column name="string_" length="48" index="fbstridx"/> - </property> - <property name="byte" column="byte_"/> - <property name="yesno" type="yes_no"/> - <property name="blob" type="org.hibernate.test.legacy.Foo$Struct" column="blobb_"/> - <property name="nullBlob" type="serializable"/> - <property name="binary" column="bin_"/> - <property name="theLocale" access="field" column="`localeayzabc123`"/> - - <property name="formula" formula="int_/2"/> - - <property name="custom" type="org.hibernate.test.legacy.DoubleStringType" access="field"> - <column name="first_name" length="66"/> - <column name="surname" length="66"/> - </property> - <component name="nullComponent"> - <property name="name" column="null_cmpnt_"/> - </component> - - <join table="jointable"> - <key column="fooid" on-delete="cascade"/> - <property name="joinedProp"/> - </join> - - <subclass - name="Trivial" - proxy="FooProxy" - discriminator-value="T"/> - - <subclass - name="Abstract" - proxy="AbstractProxy" - discriminator-value="null"> - <set name="abstracts" batch-size="2"> - <key column="abstract_id"/> - <one-to-many class="Abstract"/> - </set> - <property name="time" column="the_time"/> - - <subclass - name="Bar" - proxy="BarProxy" - discriminator-value="B"> - <property name="barString"> - <column name="bar_string" length="24"/> - </property> - <any name="object" meta-type="character" id-type="long" cascade="all"> - <meta-value value="O" class="One"/> - <meta-value value="M" class="Many"/> - <column name="clazz" length="100"/> - <column name="gen_id"/> - </any> - <join table="bar_join_table"> - <key column="bar_id"/> - <property name="name" column="name_name"/> - </join> - </subclass> - </subclass> - </class> - - <class name="One" table="one"> - <id name="key" column="one_key"> - <generator class="native" /> - </id> - <property name="x"/> - <property column="one_value" name="value"/> - </class> - - <class name="Many" table="many"> - <id name="key" column="many_key"> - <generator class="native" /> - </id> - <property name="x"/> - </class> - -</hibernate-mapping> - + assembly="NHibernate.DomainModel" + namespace="NHibernate.DomainModel" + default-lazy="false"> + + <!-- a slightly modified copy of FooBar.hbm.xml from the legacy test package --> + + <class + name="Foo" + table="`foos`" + proxy="FooProxy" + discriminator-value="F" + batch-size="4" + dynamic-insert="true" + dynamic-update="true" + select-before-update="true"> + + <id name="key" type="string"> + <column name="`foo_idcolumnname123`" length="36"/> + <generator class="uuid.hex"> + <param name="seperator">:</param> + </generator> + </id> + + <discriminator column="`foo_subclass_1234`" type="character" force="true"/> + <version name="version"/> + + <many-to-one name="foo" class="Foo"> + <column name="foo" length="36" index="fbmtoidx"/> + </many-to-one> + + <property name="Long"> + <column name="long_" index="fbmtoidx" unique-key="abc" not-null="true"/> + </property> + <property name="Integer"> + <column name="`integer__`" unique-key="abc" not-null="true"/> + </property> + <property name="Float"> + <column name="float_" unique-key="abc" not-null="true" check="float_ > 0.0"/> + </property> + <property name="x"/> + <property name="Double" column="double_"/> + + <primitive-array name="bytes" table="foobytes"> + <key column="id"/> + <index column="i"/> + <element column="byte_" type="byte"/> + </primitive-array> + + <property name="Date" type="date" column="date_"/> + <property name="Timestamp" type="timestamp" column="timestamp_"/> + <property name="Boolean" column="boolean_"/> + <property name="Bool" column="bool_"/> + <property name="Null" column="null_"/> + <property name="Short" column="short_"/> + <property name="Char" column="char_"/> + <property name="Zero" column="zero_"/> + <property name="Int" column="int_"/> + <property name="String"> + <column name="string_" length="48" index="fbstridx"/> + </property> + <property name="Byte" column="byte_"/> + <property name="YesNo" type="yes_no"/> + <!-- + <property name="blob" type="org.hibernate.test.legacy.Foo$Struct" column="blobb_"/> + <property name="nullBlob" type="serializable"/> + <property name="binary" column="bin_"/> + --> + <property name="Locale" column="`localeayzabc123`" access="field.camelcase-underscore" type="locale"/> + + <property name="formula" formula="int_*2"/> + + <property name="Custom" type="NHibernate.DomainModel.DoubleStringType, NHibernate.DomainModel" access="field.camelcase"> + <column name="first_name" length="66"/> + <column name="surname" length="66"/> + </property> + + <component name="nullComponent"> + <property name="name" column="null_cmpnt_"/> + </component> + + <join table="jointable"> + <key column="fooid" on-delete="cascade"/> + <property name="joinedProp"/> + </join> + + <subclass + name="Trivial" + proxy="FooProxy" + discriminator-value="T"/> + + <subclass + name="Abstract" + proxy="AbstractProxy" + discriminator-value="null"> + <set name="abstracts" batch-size="2"> + <key column="abstract_id"/> + <one-to-many class="Abstract"/> + </set> + <property name="time" column="the_time"/> + + <subclass + name="Bar" + proxy="BarProxy" + discriminator-value="B"> + <property name="barString"> + <column name="bar_string" length="24"/> + </property> + <any name="object" meta-type="character" id-type="long" cascade="all"> + <meta-value value="O" class="One"/> + <meta-value value="M" class="Many"/> + <column name="clazz" length="100"/> + <column name="gen_id"/> + </any> + <join table="bar_join_table"> + <key column="bar_id"/> + <property name="name" column="name_name"/> + </join> + </subclass> + </subclass> + </class> + + <class name="One" table="one"> + <id name="key" column="one_key"> + <generator class="native" /> + </id> + <property name="x"/> + <property column="one_value" name="value"/> + </class> + + <class name="Many" table="many"> + <id name="key" column="many_key"> + <generator class="native" /> + </id> + <property name="x"/> + </class> + +</hibernate-mapping> + Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Human.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Human.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Human.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,95 @@ +using System.Collections; +using Iesi.Collections; + +namespace NHibernate.Test.HQL.Ast +{ + public class Human: Mammal + { + private Name name; + private string nickName; + private ICollection friends; + private ICollection pets; + private IDictionary family; + private double height; + + private long bigIntegerValue; + private decimal bigDecimalValue; + private int intValue; + private float floatValue; + + private ISet nickNames; + private IDictionary addresses; + + public virtual Name Name + { + get { return name; } + set { name = value; } + } + + public virtual string NickName + { + get { return nickName; } + set { nickName = value; } + } + + public virtual ICollection Friends + { + get { return friends; } + set { friends = value; } + } + + public virtual ICollection Pets + { + get { return pets; } + set { pets = value; } + } + + public virtual IDictionary Family + { + get { return family; } + set { family = value; } + } + + public virtual double Height + { + get { return height; } + set { height = value; } + } + + public virtual long BigIntegerValue + { + get { return bigIntegerValue; } + set { bigIntegerValue = value; } + } + + public virtual decimal BigDecimalValue + { + get { return bigDecimalValue; } + set { bigDecimalValue = value; } + } + + public virtual int IntValue + { + get { return intValue; } + set { intValue = value; } + } + + public virtual float FloatValue + { + get { return floatValue; } + set { floatValue = value; } + } + + public virtual ISet NickNames + { + get { return nickNames; } + set { nickNames = value; } + } + + public virtual IDictionary Addresses + { + get { return addresses; } + set { addresses = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/IntegerVersioned.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/IntegerVersioned.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/IntegerVersioned.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class IntegerVersioned + { + private long id; + private int version; + private string name; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual int Version + { + get { return version; } + set { version = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Joiner.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Joiner.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Joiner.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class Joiner + { + private long id; + private string name; + private string joinedName; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual string JoinedName + { + get { return joinedName; } + set { joinedName = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,83 @@ +using System; + +namespace NHibernate.Test.HQL.Ast +{ + public class KeyManyToOneEntity + { + private Id id; + private string name; + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public class Id + { + private KeyManyToOneKeyEntity key1; + private string key2; + private int? requestedHash; + + protected Id() {} + + public Id(KeyManyToOneKeyEntity key1, string key2) + { + if (key1 == null) + { + throw new ArgumentNullException("key1"); + } + if (key2 == null) + { + throw new ArgumentNullException("key2"); + } + + this.key1 = key1; + this.key2 = key2; + + } + + public virtual KeyManyToOneKeyEntity Key1 + { + get { return key1; } + set { key1 = value; } + } + + public virtual string Key2 + { + get { return key2; } + set { key2 = value; } + } + + public override bool Equals(object obj) + { + return Equals(obj as Id); + } + + public bool Equals(Id other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.key1, key1) && Equals(other.key2, key2); + } + + public override int GetHashCode() + { + if (!requestedHash.HasValue) + { + unchecked + { + requestedHash = ((key1 != null ? key1.GetHashCode() : 0) * 397) ^ (key2 != null ? key2.GetHashCode() : 0); + } + } + return requestedHash.Value; + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -3,19 +3,19 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.HQL.Ast"> - <class name="KeyManyToOneKeyEntity"> - <id name="id" type="long" access="field" > - <generator class="native"/> - </id> - <property name="Name" type="string"/> - </class> - - <class name="KeyManyToOneEntity"> - <composite-id name="id" access="field" class="KeyManyToOneEntity$Id" unsaved-value="undefined" > - <key-many-to-one name="key1" class="KeyManyToOneKeyEntity" /> - <key-property name="key2" type="string"/> - </composite-id> - <property name="Name" type="string"/> - </class> - + <class name="KeyManyToOneKeyEntity"> + <id name="id" type="long" access="field" > + <generator class="native"/> + </id> + <property name="Name" type="string"/> + </class> + + <class name="KeyManyToOneEntity"> + <composite-id name="id" access="field" class="KeyManyToOneEntity+Id" unsaved-value="undefined" > + <key-many-to-one name="Key1" class="KeyManyToOneKeyEntity" /> + <key-property name="Key2" type="string"/> + </composite-id> + <property name="Name" type="string"/> + </class> + </hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneKeyEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneKeyEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneKeyEntity.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,52 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class KeyManyToOneKeyEntity + { + private long id; + private string name; + private int? requestedHash; + + protected KeyManyToOneKeyEntity() {} + + public KeyManyToOneKeyEntity(string name) + { + this.name = name; + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public override bool Equals(object obj) + { + return Equals(obj as KeyManyToOneKeyEntity); + } + + public virtual bool Equals(KeyManyToOneKeyEntity other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return other.id == id && Equals(other.name, name); + } + + public override int GetHashCode() + { + if(!requestedHash.HasValue) + { + unchecked + { + requestedHash = (id.GetHashCode() * 397) ^ (name != null ? name.GetHashCode() : 0); + } + } + return requestedHash.Value; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Mammal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Mammal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Mammal.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,22 @@ +using System; + +namespace NHibernate.Test.HQL.Ast +{ + public class Mammal: Animal + { + private bool pregnant; + private DateTime birthdate; + + public virtual bool Pregnant + { + get { return pregnant; } + set { pregnant = value; } + } + + public virtual DateTime Birthdate + { + get { return birthdate; } + set { birthdate = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -1,101 +1,104 @@ <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" - assembly="NHibernate.Test" - namespace="NHibernate.Test.HQL.Ast" + assembly="NHibernate.DomainModel" + namespace="NHibernate.DomainModel" default-lazy="false"> - <class - name="org.hibernate.test.legacy.Top" - table="rootclass" - dynamic-insert="true" - dynamic-update="true" - select-before-update="true" - where="id1_ is not null"> - <!--cache--> - <id name="id" type="long" column="id1_" unsaved-value="0"> - <generator class="native"/> - </id> - <version name="count" column="count_"/> - <property name="name"/> - <property name="address"/> - <property name="date" column="date_"/> - <many-to-one name="top" access="field" column="top_"/> - - <joined-subclass name="org.hibernate.test.legacy.TrivialClass"> - <key column="tcid"/> - </joined-subclass> - - <joined-subclass - name="org.hibernate.test.legacy.Lower" - table="leafsubclass" - dynamic-insert="true" - dynamic-update="true"> - <key column="id__"/> - <property name="intprop" not-null="true"/> - <one-to-one name="other" class="org.hibernate.test.legacy.Lower"/> - <many-to-one name="another" column="other1" class="org.hibernate.test.legacy.Top"/> - <many-to-one name="yetanother" column="other3" class="org.hibernate.test.legacy.Lower"/> - <property name="foo"/> - <set name="set" lazy="false"> - <key column="parent"/> - <one-to-many class="org.hibernate.test.legacy.Top"/> - </set> - <bag name="bag" lazy="true" table="simple_simple"> - <key column="simple1"/> - <many-to-many column="simple2" class="org.hibernate.test.legacy.Top"/> - </bag> - <one-to-one name="mypo"/> - </joined-subclass> - - <joined-subclass name="org.hibernate.test.legacy.Multi" table="nonleafsubclass"> - <key column="sid" on-delete="cascade"/> - <property name="extraProp" column="dupe"/> - <many-to-one name="other" column="other2" class="org.hibernate.test.legacy.Multi" /> - <many-to-one name="po"/> - <property name="derived" formula="upper(dupe)"/> - - <component name="comp" class="org.hibernate.test.legacy.Multi$Component"> - <property name="cal"/> - <property name="floaty"/> - </component> - - <joined-subclass name="org.hibernate.test.legacy.SubMulti" table="leafsubsubclass"> - <key column="sid"/> - <property name="amount" column="dupe"/> - <bag name="children" lazy="true" inverse="true"> - <key column="parent"/> - <one-to-many class="org.hibernate.test.legacy.SubMulti"/> - </bag> - <many-to-one name="parent"/> - <list name="moreChildren" lazy="true"> - <key column="another_parent"/> - <index column="list_ind"/> - <one-to-many class="org.hibernate.test.legacy.SubMulti"/> - </list> - </joined-subclass> - - </joined-subclass> - - </class> - - <class - name="org.hibernate.test.legacy.Po" - dynamic-insert="true"> - <id type="long" column="id_"> - <generator class="native"/> - </id> - <property name="value" column="value_"/> - <list name="list" cascade="all"> - <key column="list_po"/> - <index column="i"/> - <one-to-many class="org.hibernate.test.legacy.SubMulti"/> - </list> - <set name="set" inverse="true" cascade="all"> - <key column="po"/> - <one-to-many class="org.hibernate.test.legacy.Multi"/> - </set> - <many-to-one name="top" column="tl" insert="false" update="false"/> - <many-to-one name="lower" column="tl"/> - </class> - + <class + name="Top" + table="rootclass" + dynamic-insert="true" + dynamic-update="true" + select-before-update="true" + where="id1_ is not null" + > + <!--<jcs-cache usage="read-write"/> --> + <!-- commented out in h2.1 test also --> + <id name="Id" type="Int64" column="id1_" unsaved-value="0"> + <generator class="native"/> + </id> + + <version name="Count" column="count_" /> + <property name="Name" /> + <property name="Address" /> + <property name="Date" column="date_" /> + <many-to-one name="top" access="field" column="`_top`"/> + <!-- changed column name because of MSSQL conflicts --> + <joined-subclass name="TrivialClass"> + <key column="tcid"/> + </joined-subclass> + + <joined-subclass name="Lower" + table="leafsubclass" dynamic-insert="true" dynamic-update="true"> + <key column="id__"/> + <property name="Intprop" not-null="true" /> + <one-to-one name="Other" class="Lower" /> + <many-to-one name="Another" column="other1" class="Top" /> + <many-to-one name="YetAnother" column="other3" class="Lower" /> + <property name="Foo"/> + <set name="Set" lazy="false"> + <key column="parent"/> + <one-to-many class="Top"/> + </set> + <bag name="Bag" lazy="true" table="simple_simple"> + <key column="simple1"/> + <many-to-many column="simple2" class="Top" + /> + </bag> + <one-to-one name="MyPo"/> + </joined-subclass> + + <joined-subclass name="Multi" table="nonleafsubclass"> + <key column="sid"/> + <property name="ExtraProp" column="dupe"/> + <many-to-one name="Other" column="other2" class="Multi" /> + <many-to-one name="Po" column="po"/> + <many-to-one name="OtherPo" /> + <property name="Derived" formula="upper(dupe)" /> + <component name="Comp" class="Multi+Component"> + <property name="Cal"/> + <property name="Floaty"/> + </component> + + <joined-subclass name="SubMulti" table="leafsubsubclass"> + <key column="sid"/> + <property name="Amount" column="dupe"/> + <bag name="Children" lazy="true" inverse="true" > + <key column="parent"/> + <one-to-many class="SubMulti"/> + </bag> + <many-to-one name="Parent" column="parent" /> + <list name="MoreChildren" lazy="true"> + <key column="another_parent"/> + <index column="list_ind"/> + <one-to-many class="SubMulti"/> + </list> + </joined-subclass> + + </joined-subclass> + + </class> + + <class name="NHibernate.DomainModel.Po, NHibernate.DomainModel" dynamic-insert="true"> + <id type="Int64" column="id_" unsaved-value="0"> + <generator class="native"/> + </id> + <property name="Value" column="value_" /> + <list name="List" cascade="all" > + <key column="list_po"/> + <index column="i"/> + <one-to-many class="NHibernate.DomainModel.SubMulti, NHibernate.DomainModel" /> + </list> + <set name="Set" inverse="true" cascade="all" lazy="true"> + <key column="po" /> + <one-to-many class="NHibernate.DomainModel.Multi, NHibernate.DomainModel" /> + </set> + <set name="EagerSet" inverse="true" cascade="all" outer-join="true"> + <key column="OtherPo" /> + <one-to-many class="NHibernate.DomainModel.Multi, NHibernate.DomainModel" /> + </set> + <many-to-one name="Top" column="t1" insert="false" update="false" /> + <many-to-one name="Lower" column="t1" /> + </class> + </hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Name.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Name.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Name.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class Name + { + private string first; + private char initial; + private string last; + + public string First + { + get { return first; } + set { first = value; } + } + + public char Initial + { + get { return initial; } + set { initial = value; } + } + + public string Last + { + get { return last; } + set { last = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Reptile.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Reptile.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Reptile.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,14 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class Reptile: Animal + { + private float bodyTemperature; + public virtual float BodyTemperature + { + get { return bodyTemperature; } + set { bodyTemperature = value; } + } + } + + public class Lizard : Reptile { } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleAssociatedEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleAssociatedEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleAssociatedEntity.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,77 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class SimpleAssociatedEntity + { + private long id; + private string name; + private int? requestedHash; + private SimpleEntityWithAssociation owner; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual SimpleEntityWithAssociation Owner + { + get { return owner; } + set { owner = value; } + } + + public virtual void BindToOwner(SimpleEntityWithAssociation owner) + { + if (owner != this.owner) + { + UnbindFromCurrentOwner(); + if (owner != null) + { + owner.AssociatedEntities.Add(this); + } + } + this.owner = owner; + } + + public virtual void UnbindFromCurrentOwner() + { + if (owner != null) + { + owner.AssociatedEntities.Remove(this); + owner = null; + } + } + + public override bool Equals(object obj) + { + return Equals(obj as SimpleAssociatedEntity); + } + + public virtual bool Equals(SimpleAssociatedEntity other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.Id, Id); + } + + public override int GetHashCode() + { + if (!requestedHash.HasValue) + { + requestedHash = Id.GetHashCode(); + } + return requestedHash.Value; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,36 @@ +using Iesi.Collections; + +namespace NHibernate.Test.HQL.Ast +{ + public class SimpleEntityWithAssociation + { + private long id; + private string name; + private ISet associatedEntities = new HashedSet(); + private ISet manyToManyAssociatedEntities = new HashedSet(); + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual ISet AssociatedEntities + { + get { return associatedEntities; } + set { associatedEntities = value; } + } + + public virtual ISet ManyToManyAssociatedEntities + { + get { return manyToManyAssociatedEntities; } + set { manyToManyAssociatedEntities = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -3,29 +3,29 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.HQL.Ast"> - <!-- *Very* important for the test cases that these entities have identically named columns! --> - - <class name="SimpleEntityWithAssociation" table="SIMPLE_1"> - <id name="Id" column="ID" type="long"> - <generator class="native"/> - </id> - <property name="Name" column="NAME" type="string"/> - <set name="AssociatedEntities" cascade="all" inverse="true" lazy="true"> - <key column="SIMPLE_1_ID"/> - <one-to-many class="SimpleAssociatedEntity"/> - </set> - <set name="ManyToManyAssociatedEntities" cascade="save-update" inverse="false" lazy="true" table="MANY_TO_MANY"> - <key column="IN_ID"/> - <many-to-many class="SimpleEntityWithAssociation" column="OUT_ID"/> - </set> - </class> - - <class name="SimpleAssociatedEntity" table="SIMPLE_2"> - <id name="Id" column="ID" type="long"> - <generator class="native"/> - </id> - <property name="Name" column="NAME" type="string" /> - <many-to-one name="Owner" class="SimpleEntityWithAssociation" column="SIMPLE_1_ID"/> - </class> - + <!-- *Very* important for the test cases that these entities have identically named columns! --> + + <class name="SimpleEntityWithAssociation" table="SIMPLE_1"> + <id name="Id" column="ID" type="long"> + <generator class="native"/> + </id> + <property name="Name" column="NAME" type="string"/> + <set name="AssociatedEntities" cascade="all" inverse="true" lazy="true"> + <key column="SIMPLE_1_ID"/> + <one-to-many class="SimpleAssociatedEntity"/> + </set> + <set name="ManyToManyAssociatedEntities" cascade="save-update" inverse="false" lazy="true" table="MANY_TO_MANY"> + <key column="IN_ID"/> + <many-to-many class="SimpleEntityWithAssociation" column="OUT_ID"/> + </set> + </class> + + <class name="SimpleAssociatedEntity" table="SIMPLE_2"> + <id name="Id" column="ID" type="long"> + <generator class="native"/> + </id> + <property name="Name" column="NAME" type="string" /> + <many-to-one name="Owner" class="SimpleEntityWithAssociation" column="SIMPLE_1_ID"/> + </class> + </hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/StateProvince.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/StateProvince.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/StateProvince.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class StateProvince + { + private long id; + private string name; + private string isoCode; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual string IsoCode + { + get { return isoCode; } + set { isoCode = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/TimestampVersioned.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/TimestampVersioned.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/TimestampVersioned.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,29 @@ +using System; + +namespace NHibernate.Test.HQL.Ast +{ + public class TimestampVersioned + { + private long id; + private DateTime version; + private string name; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual DateTime Version + { + get { return version; } + set { version = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/User.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/User.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,36 @@ +using System.Collections; + +namespace NHibernate.Test.HQL.Ast +{ + public class User + { + private long id; + private string userName; + private Human human; + private IList permissions; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string UserName + { + get { return userName; } + set { userName = value; } + } + + public virtual Human Human + { + get { return human; } + set { human = value; } + } + + public virtual IList Permissions + { + get { return permissions; } + set { permissions = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -3,27 +3,27 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.HQL.Ast"> - <!-- Vehicle represents an abstract root of a union-subclass hierarchy --> - <class name="Vehicle" abstract="true"> - <id name="id" access="field" type="long"> - <generator class="increment"/> - </id> - <property name="Vin" type="string"/> - <property name="Owner" type="string"/> - - <!-- Car represents a concrete leaf of a union-subclass hierarchy with no concrete super --> - <union-subclass name="Car"/> - - <!-- Truck represents a concrete subclass in a union-subclass hierarchy with concrete subclasses and no concrete super --> - <union-subclass name="Truck"> - <!-- Both SUV and Pickup represent concrete leaf of a union-subclass hierarchy (like Car), but with a concrete super --> - <union-subclass name="SUV"/> - <union-subclass name="Pickup"/> - </union-subclass> - </class> - - <sql-query name="native-delete-car"> - <synchronize table="Car"/> - delete from CAR where owner = ? - </sql-query> + <!-- Vehicle represents an abstract root of a union-subclass hierarchy --> + <class name="Vehicle" abstract="true"> + <id name="id" access="field" type="long"> + <generator class="increment"/> + </id> + <property name="Vin" type="string"/> + <property name="Owner" type="string"/> + + <!-- Car represents a concrete leaf of a union-subclass hierarchy with no concrete super --> + <union-subclass name="Car"/> + + <!-- Truck represents a concrete subclass in a union-subclass hierarchy with concrete subclasses and no concrete super --> + <union-subclass name="Truck"> + <!-- Both SUV and Pickup represent concrete leaf of a union-subclass hierarchy (like Car), but with a concrete super --> + <union-subclass name="SUV"/> + <union-subclass name="Pickup"/> + </union-subclass> + </class> + + <sql-query name="native-delete-car"> + <synchronize table="Car"/> + delete from CAR where owner = ? + </sql-query> </hibernate-mapping> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicles.cs (from rev 4226, trunk/nhibernate/src/NHibernate.Test/BulkManipulation/Vehicles.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicles.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicles.cs 2009-05-03 22:24:46 UTC (rev 4228) @@ -0,0 +1,43 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class Vehicle + { + private long id; + private string vin; + private string owner; + + public virtual long Id + { + get { return id; } + set { id = value; } + } + + public virtual string Vin + { + get { return vin; } + set { vin = value; } + } + + public virtual string Owner + { + get { return owner; } + set { owner = value; } + } + } + + public class Car : Vehicle + { + } + + public class Truck : Vehicle + { + } + + public class Pickup : Truck + { + } + + public class SUV : Truck + { + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml 2009-05-03 22:24:46 UTC (rev 4228) @@ -4,20 +4,20 @@ namespace="NHibernate.Test.HQL.Ast" default-access="field"> - <class name="IntegerVersioned"> - <id name="id"> - <generator class="native"/> - </id> - <version name="version" column="vers"/> - <property name="name"/> - </class> - - <class name="TimestampVersioned"> - <id name="id"> - <generator class="native"/> - </id> - <timestamp name="version" column="vers"/> - <property name="name"/> - </class> - + <class name="IntegerVersioned"> + <id name="id"> + <generator class="native"/> + </id>... [truncated message content] |
From: <fab...@us...> - 2009-05-03 14:22:26
|
Revision: 4227 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4227&view=rev Author: fabiomaulo Date: 2009-05-03 13:43:03 +0000 (Sun, 03 May 2009) Log Message: ----------- Starting port of AST tests (at least for BulkUpdates) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast" + default-access="field"> + + <class name="Animal"> + <id name="id"> + <generator class="native"/> + </id> + <property name="description"/> + <property name="bodyWeight" column="body_weight"/> + <many-to-one name="mother" column="mother_id"/> + <many-to-one name="father" column="father_id"/> + <many-to-one name="zoo" column="zoo_id"/> + <property name="serialNumber"/> + <set name="offspring" order-by="father_id"> + <key column="mother_id"/> + <one-to-many class="Animal"/> + </set> + <joined-subclass name="Reptile"> + <key column="animal"/> + <property name="bodyTemperature"/> + <joined-subclass name="Lizard"> + <key column="reptile"/> + </joined-subclass> + </joined-subclass> + <joined-subclass name="Mammal"> + <key column="animal"/> + <property name="pregnant"/> + <property name="birthdate" type="date"/> + <joined-subclass name="DomesticAnimal"> + <key column="mammal"/> + <many-to-one name="owner"/> + <joined-subclass name="Cat"> + <key column="mammal"/> + </joined-subclass> + <joined-subclass name="Dog"> + <key column="mammal"/> + </joined-subclass> + </joined-subclass> + <joined-subclass name="Human"> + <key column="mammal"/> + <component name="name"> + <property name="first" column="name_first"/> + <property name="initial" column="name_initial"/> + <property name="last" column="name_last"/> + </component> + <property name="nickName"/> + <property name="height"/> + + <property name="intValue"/> + <property name="floatValue"/> + <property name="bigDecimalValue"/> + <property name="bigIntegerValue"/> + + <bag name="friends"> + <key column="human1"/> + <many-to-many column="human2" class="Human"/> + </bag> + <map name="family"> + <key column="human1"/> + <map-key column="relationship" type="string"/> + <many-to-many column="human2" class="Human"/> + </map> + <bag name="pets" inverse="true"> + <key column="owner"/> + <one-to-many class="DomesticAnimal"/> + </bag> + <set name="nickNames" lazy="false" table="human_nick_names" sort="natural"> + <key column="human"/> + <element column="nick_name" type="string" not-null="true"/> + </set> + <map name="addresses" table="addresses"> + <key column="human"/> + <map-key type="string" column="type"/> + <composite-element class="Address"> + <property name="street"/> + <property name="city"/> + <property name="postalCode"/> + <property name="country"/> + <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> + </composite-element> + </map> + </joined-subclass> + </joined-subclass> + </class> + + <class name="User" table="`User`"> + <id name="id"> + <generator class="foreign"> + <param name="property">human</param> + </generator> + </id> + <property name="userName"/> + <one-to-one name="human" constrained="true"/> + <list name="permissions"> + <key column="userId"/> + <list-index column="permissionId"/> + <element type="string" column="permissionName"/> + </list> + </class> + + <class name="Zoo" discriminator-value="Z"> + <id name="id"> + <generator class="native"/> + </id> + <discriminator column="zooType" type="character"/> + <property name="name" type="string"/> + <property name="classification" type="org.hibernate.test.hql.ClassificationType"/> + <map name="mammals"> + <key column="mammalZoo_id"/> + <index type="string" column="name"/> + <one-to-many class="Mammal"/> + </map> + <map name="animals" inverse="true"> + <key column="zoo_id"/> + <index type="string" column="serialNumber"/> + <one-to-many class="Animal"/> + </map> + <component name="address" class="Address"> + <property name="street"/> + <property name="city"/> + <property name="postalCode"/> + <property name="country"/> + <many-to-one name="stateProvince" column="state_prov_id" class="StateProvince"/> + </component> + <subclass name="PettingZoo" discriminator-value="P"/> + </class> + + <class name="StateProvince"> + <id name="id"> + <generator class="native"/> + </id> + <property name="name"/> + <property name="isoCode"/> + </class> + + <class name="Joiner"> + <id name="id"> + <generator class="native"/> + </id> + <property name="name"/> + <join table="JOINED"> + <key column="ID"/> + <property name="joinedName"/> + </join> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs 2009-05-03 12:37:55 UTC (rev 4226) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs 2009-05-03 13:43:03 UTC (rev 4227) @@ -2,6 +2,7 @@ using NHibernate.Hql.Ast.ANTLR; using System.Collections.Generic; using NHibernate.Util; +using NHibernate.Hql.Classic; namespace NHibernate.Test.HQL.Ast { @@ -11,7 +12,7 @@ protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) { - return sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory; + return !(sessions.Settings.QueryTranslatorFactory is ClassicQueryTranslatorFactory); } #region Overrides of TestCase Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BooleanLiteralEntity.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast"> + + <class name="BooleanLiteralEntity"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="YesNoBoolean" column="Y_N_BOOL" type="yes_no"/> + <property name="TrueFalseBoolean" column="T_F_BOOL" type="true_false"/> + <property name="ZeroOneBoolean" column="NUM_BOOL" type="boolean"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,15 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class BulkManipulation: BaseFixture + { + // "hql/Animal.hbm.xml", + // "hql/Vehicle.hbm.xml", + // "hql/KeyManyToOneEntity.hbm.xml", + // "hql/Versions.hbm.xml", + //"hql/FooBarCopy.hbm.xml", + //"legacy/Multi.hbm.xml", + //"hql/EntityWithCrazyCompositeKey.hbm.xml", + //"hql/SimpleEntityWithAssociation.hbm.xml", + //"hql/BooleanLiteralEntity.hbm.xml" + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/EntityWithCrazyCompositeKey.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast"> + + <class name="EntityWithCrazyCompositeKey"> + <composite-id name="Id" class="CrazyCompositeKey"> + <key-property name="Id" column="id"/> + <key-property name="OtherId" column="other_id"/> + </composite-id> + <property name="Name"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/FooBarCopy.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast" + default-lazy="false"> + + <!-- a slightly modified copy of FooBar.hbm.xml from the legacy test package --> + + <class + name="Foo" + table="`foos`" + proxy="FooProxy" + discriminator-value="F" + batch-size="4" + dynamic-insert="true" + dynamic-update="true" + select-before-update="true"> + + <id name="key" type="string"> + <column name="`foo_idcolumnname123`" length="36"/> + <generator class="uuid.hex"> + <param name="seperator">:</param> + </generator> + </id> + + <discriminator column="`foo_subclass_1234`" type="character" force="true"/> + <version name="version"/> + + <many-to-one name="foo" class="Foo"> + <column name="foo" length="36" index="fbmtoidx"/> + </many-to-one> + + <property name="long"> + <column name="long_" index="fbmtoidx" unique-key="abc" not-null="true"/> + </property> + <property name="integer"> + <column name="`integer__`" unique-key="abc" not-null="true"/> + </property> + <property name="float"> + <column name="float_" unique-key="abc" not-null="true" check="float_ > 0.0"/> + </property> + <property name="x"/> + <property name="double" column="double_"/> + + <primitive-array name="bytes" table="foobytes"> + <key column="id"/> + <index column="i"/> + <element column="byte_" type="byte"/> + </primitive-array> + + <property name="date" type="date" column="date_"/> + <property name="timestamp" type="timestamp" column="timestamp_"/> + <property name="boolean" column="boolean_"/> + <property name="bool" column="bool_"/> + <property name="null" column="null_"/> + <property name="short" column="short_"/> + <property name="char" column="char_"/> + <property name="zero" column="zero_"/> + <property name="int" column="int_"/> + <property name="string"> + <column name="string_" length="48" index="fbstridx"/> + </property> + <property name="byte" column="byte_"/> + <property name="yesno" type="yes_no"/> + <property name="blob" type="org.hibernate.test.legacy.Foo$Struct" column="blobb_"/> + <property name="nullBlob" type="serializable"/> + <property name="binary" column="bin_"/> + <property name="theLocale" access="field" column="`localeayzabc123`"/> + + <property name="formula" formula="int_/2"/> + + <property name="custom" type="org.hibernate.test.legacy.DoubleStringType" access="field"> + <column name="first_name" length="66"/> + <column name="surname" length="66"/> + </property> + <component name="nullComponent"> + <property name="name" column="null_cmpnt_"/> + </component> + + <join table="jointable"> + <key column="fooid" on-delete="cascade"/> + <property name="joinedProp"/> + </join> + + <subclass + name="Trivial" + proxy="FooProxy" + discriminator-value="T"/> + + <subclass + name="Abstract" + proxy="AbstractProxy" + discriminator-value="null"> + <set name="abstracts" batch-size="2"> + <key column="abstract_id"/> + <one-to-many class="Abstract"/> + </set> + <property name="time" column="the_time"/> + + <subclass + name="Bar" + proxy="BarProxy" + discriminator-value="B"> + <property name="barString"> + <column name="bar_string" length="24"/> + </property> + <any name="object" meta-type="character" id-type="long" cascade="all"> + <meta-value value="O" class="One"/> + <meta-value value="M" class="Many"/> + <column name="clazz" length="100"/> + <column name="gen_id"/> + </any> + <join table="bar_join_table"> + <key column="bar_id"/> + <property name="name" column="name_name"/> + </join> + </subclass> + </subclass> + </class> + + <class name="One" table="one"> + <id name="key" column="one_key"> + <generator class="native" /> + </id> + <property name="x"/> + <property column="one_value" name="value"/> + </class> + + <class name="Many" table="many"> + <id name="key" column="many_key"> + <generator class="native" /> + </id> + <property name="x"/> + </class> + +</hibernate-mapping> + Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/KeyManyToOneEntity.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast"> + + <class name="KeyManyToOneKeyEntity"> + <id name="id" type="long" access="field" > + <generator class="native"/> + </id> + <property name="Name" type="string"/> + </class> + + <class name="KeyManyToOneEntity"> + <composite-id name="id" access="field" class="KeyManyToOneEntity$Id" unsaved-value="undefined" > + <key-many-to-one name="key1" class="KeyManyToOneKeyEntity" /> + <key-property name="key2" type="string"/> + </composite-id> + <property name="Name" type="string"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Multi.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast" + default-lazy="false"> + + <class + name="org.hibernate.test.legacy.Top" + table="rootclass" + dynamic-insert="true" + dynamic-update="true" + select-before-update="true" + where="id1_ is not null"> + <!--cache--> + <id name="id" type="long" column="id1_" unsaved-value="0"> + <generator class="native"/> + </id> + <version name="count" column="count_"/> + <property name="name"/> + <property name="address"/> + <property name="date" column="date_"/> + <many-to-one name="top" access="field" column="top_"/> + + <joined-subclass name="org.hibernate.test.legacy.TrivialClass"> + <key column="tcid"/> + </joined-subclass> + + <joined-subclass + name="org.hibernate.test.legacy.Lower" + table="leafsubclass" + dynamic-insert="true" + dynamic-update="true"> + <key column="id__"/> + <property name="intprop" not-null="true"/> + <one-to-one name="other" class="org.hibernate.test.legacy.Lower"/> + <many-to-one name="another" column="other1" class="org.hibernate.test.legacy.Top"/> + <many-to-one name="yetanother" column="other3" class="org.hibernate.test.legacy.Lower"/> + <property name="foo"/> + <set name="set" lazy="false"> + <key column="parent"/> + <one-to-many class="org.hibernate.test.legacy.Top"/> + </set> + <bag name="bag" lazy="true" table="simple_simple"> + <key column="simple1"/> + <many-to-many column="simple2" class="org.hibernate.test.legacy.Top"/> + </bag> + <one-to-one name="mypo"/> + </joined-subclass> + + <joined-subclass name="org.hibernate.test.legacy.Multi" table="nonleafsubclass"> + <key column="sid" on-delete="cascade"/> + <property name="extraProp" column="dupe"/> + <many-to-one name="other" column="other2" class="org.hibernate.test.legacy.Multi" /> + <many-to-one name="po"/> + <property name="derived" formula="upper(dupe)"/> + + <component name="comp" class="org.hibernate.test.legacy.Multi$Component"> + <property name="cal"/> + <property name="floaty"/> + </component> + + <joined-subclass name="org.hibernate.test.legacy.SubMulti" table="leafsubsubclass"> + <key column="sid"/> + <property name="amount" column="dupe"/> + <bag name="children" lazy="true" inverse="true"> + <key column="parent"/> + <one-to-many class="org.hibernate.test.legacy.SubMulti"/> + </bag> + <many-to-one name="parent"/> + <list name="moreChildren" lazy="true"> + <key column="another_parent"/> + <index column="list_ind"/> + <one-to-many class="org.hibernate.test.legacy.SubMulti"/> + </list> + </joined-subclass> + + </joined-subclass> + + </class> + + <class + name="org.hibernate.test.legacy.Po" + dynamic-insert="true"> + <id type="long" column="id_"> + <generator class="native"/> + </id> + <property name="value" column="value_"/> + <list name="list" cascade="all"> + <key column="list_po"/> + <index column="i"/> + <one-to-many class="org.hibernate.test.legacy.SubMulti"/> + </list> + <set name="set" inverse="true" cascade="all"> + <key column="po"/> + <one-to-many class="org.hibernate.test.legacy.Multi"/> + </set> + <many-to-one name="top" column="tl" insert="false" update="false"/> + <many-to-one name="lower" column="tl"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleEntityWithAssociation.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast"> + + <!-- *Very* important for the test cases that these entities have identically named columns! --> + + <class name="SimpleEntityWithAssociation" table="SIMPLE_1"> + <id name="Id" column="ID" type="long"> + <generator class="native"/> + </id> + <property name="Name" column="NAME" type="string"/> + <set name="AssociatedEntities" cascade="all" inverse="true" lazy="true"> + <key column="SIMPLE_1_ID"/> + <one-to-many class="SimpleAssociatedEntity"/> + </set> + <set name="ManyToManyAssociatedEntities" cascade="save-update" inverse="false" lazy="true" table="MANY_TO_MANY"> + <key column="IN_ID"/> + <many-to-many class="SimpleEntityWithAssociation" column="OUT_ID"/> + </set> + </class> + + <class name="SimpleAssociatedEntity" table="SIMPLE_2"> + <id name="Id" column="ID" type="long"> + <generator class="native"/> + </id> + <property name="Name" column="NAME" type="string" /> + <many-to-one name="Owner" class="SimpleEntityWithAssociation" column="SIMPLE_1_ID"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast"> + + <!-- Vehicle represents an abstract root of a union-subclass hierarchy --> + <class name="Vehicle" abstract="true"> + <id name="id" access="field" type="long"> + <generator class="increment"/> + </id> + <property name="Vin" type="string"/> + <property name="Owner" type="string"/> + + <!-- Car represents a concrete leaf of a union-subclass hierarchy with no concrete super --> + <union-subclass name="Car"/> + + <!-- Truck represents a concrete subclass in a union-subclass hierarchy with concrete subclasses and no concrete super --> + <union-subclass name="Truck"> + <!-- Both SUV and Pickup represent concrete leaf of a union-subclass hierarchy (like Car), but with a concrete super --> + <union-subclass name="SUV"/> + <union-subclass name="Pickup"/> + </union-subclass> + </class> + + <sql-query name="native-delete-car"> + <synchronize table="Car"/> + delete from CAR where owner = ? + </sql-query> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Versions.hbm.xml 2009-05-03 13:43:03 UTC (rev 4227) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.HQL.Ast" + default-access="field"> + + <class name="IntegerVersioned"> + <id name="id"> + <generator class="native"/> + </id> + <version name="version" column="vers"/> + <property name="name"/> + </class> + + <class name="TimestampVersioned"> + <id name="id"> + <generator class="native"/> + </id> + <timestamp name="version" column="vers"/> + <property name="name"/> + </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-05-03 12:37:55 UTC (rev 4226) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-03 13:43:03 UTC (rev 4227) @@ -293,6 +293,7 @@ <Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" /> <Compile Include="HQL\Animal.cs" /> <Compile Include="HQL\Ast\BaseFixture.cs" /> + <Compile Include="HQL\Ast\BulkManipulation.cs" /> <Compile Include="HQL\Ast\ParsingFixture.cs" /> <Compile Include="HQL\Ast\SimpleClass.cs" /> <Compile Include="HQL\Ast\SqlTranslationFixture.cs" /> @@ -1724,6 +1725,15 @@ <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <Content Include="HQL\Ast\Animal.hbm.xml" /> + <Content Include="HQL\Ast\BooleanLiteralEntity.hbm.xml" /> + <Content Include="HQL\Ast\EntityWithCrazyCompositeKey.hbm.xml" /> + <Content Include="HQL\Ast\FooBarCopy.hbm.xml" /> + <Content Include="HQL\Ast\KeyManyToOneEntity.hbm.xml" /> + <Content Include="HQL\Ast\Multi.hbm.xml" /> + <Content Include="HQL\Ast\SimpleEntityWithAssociation.hbm.xml" /> + <Content Include="HQL\Ast\Vehicle.hbm.xml" /> + <Content Include="HQL\Ast\Versions.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1727\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1742\Mappings.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\SimpleClass.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-03 12:38:01
|
Revision: 4226 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4226&view=rev Author: fabiomaulo Date: 2009-05-03 12:37:55 +0000 (Sun, 03 May 2009) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-02 22:39:05 UTC (rev 4225) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-03 12:37:55 UTC (rev 4226) @@ -366,19 +366,17 @@ ISession s = OpenSession(); ITransaction t = s.BeginTransaction(); - string path = IsClassicParser ? "m.Details.elements" : "elements(m.Details)"; + string path = IsClassicParser ? "m.Details.elements" : "elements(m.Details)"; if (Dialect.SupportsSubSelects) { - s.CreateQuery("FROM m IN CLASS Master WHERE NOT EXISTS ( FROM d in " + path + " WHERE NOT d.I=5 )").Enumerable - (); - s.CreateQuery("FROM m IN CLASS Master WHERE NOT 5 IN ( SELECT d.I FROM d IN " + path + " )").Enumerable(); + s.CreateQuery("FROM m IN CLASS Master WHERE NOT EXISTS ( FROM d in " + path + " WHERE NOT d.I=5 )").Enumerable(); + s.CreateQuery("FROM m IN CLASS Master WHERE NOT 5 IN ( SELECT d.I FROM d IN " + path + " )").Enumerable(); } - s.CreateQuery("SELECT m FROM m in CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5"). - Enumerable(); - s.CreateQuery("SELECT m FROM m in CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5").List(); - s.CreateQuery("SELECT m.id FROM m IN CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5").List(); + s.CreateQuery("SELECT m FROM m in CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5").Enumerable(); + s.CreateQuery("SELECT m FROM m in CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5").List(); + s.CreateQuery("SELECT m.id FROM m IN CLASS NHibernate.DomainModel.Master, d IN " + path + " WHERE d.I=5").List(); t.Commit(); s.Close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-02 22:39:07
|
Revision: 4225 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4225&view=rev Author: fabiomaulo Date: 2009-05-02 22:39:05 +0000 (Sat, 02 May 2009) Log Message: ----------- Minor Refactoring/Reformatting Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-02 21:53:39 UTC (rev 4224) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-02 22:39:05 UTC (rev 4225) @@ -25,7 +25,7 @@ private bool _shallowQuery; private bool _compiled; - private string _queryIdentifier; + private readonly string _queryIdentifier; private readonly string _hql; private IDictionary<string, IFilter> _enabledFilters; private readonly ISessionFactoryImplementor _factory; @@ -35,7 +35,6 @@ private ParameterTranslationsImpl _paramTranslations; private IDictionary<string, string> tokenReplacements; private HqlParseEngine _parser; - private HqlSqlTranslator _translator; private HqlSqlGenerator _generator; /// <summary> @@ -96,7 +95,7 @@ { // Delegate to the QueryLoader... ErrorIfDML(); - QueryNode query = ( QueryNode ) _translator.SqlStatement; + var query = ( QueryNode ) sqlAst; bool hasLimit = queryParameters.RowSelection != null && queryParameters.RowSelection.DefinesLimits; bool needsDistincting = ( query.GetSelectClause().IsDistinct || hasLimit ) && ContainsCollectionFetches; @@ -105,9 +104,11 @@ if ( hasLimit && ContainsCollectionFetches ) { log.Warn( "firstResult/maxResults specified with collection fetch; applying in memory!" ); - RowSelection selection = new RowSelection(); - selection.FetchSize = queryParameters.RowSelection.FetchSize; - selection.Timeout = queryParameters.RowSelection.Timeout; + var selection = new RowSelection + { + FetchSize = queryParameters.RowSelection.FetchSize, + Timeout = queryParameters.RowSelection.Timeout + }; queryParametersToUse = queryParameters.CreateCopyUsing( selection ); } else @@ -129,8 +130,8 @@ : queryParameters.RowSelection.MaxRows; int size = results.Count; - List<object> tmp = new List<object>(); - IdentitySet distinction = new IdentitySet(); + var tmp = new List<object>(); + var distinction = new IdentitySet(); for ( int i = 0; i < size; i++ ) { @@ -191,14 +192,14 @@ public string[][] GetColumnNames() { ErrorIfDML(); - return _translator.SqlStatement.Walker.SelectClause.ColumnNames; + return sqlAst.Walker.SelectClause.ColumnNames; } public IParameterTranslations GetParameterTranslations() { if (_paramTranslations == null) { - _paramTranslations = new ParameterTranslationsImpl(_translator.SqlStatement.Walker.Parameters); + _paramTranslations = new ParameterTranslationsImpl(sqlAst.Walker.Parameters); } return _paramTranslations; @@ -206,7 +207,7 @@ public ISet<string> QuerySpaces { - get { return _translator.SqlStatement.Walker.QuerySpaces; } + get { return sqlAst.Walker.QuerySpaces; } } public string SQLString @@ -270,7 +271,7 @@ get { ErrorIfDML(); - return _translator.SqlStatement.Walker.ReturnTypes; + return sqlAst.Walker.ReturnTypes; } } @@ -279,7 +280,7 @@ get { ErrorIfDML(); - return _translator.SqlStatement.Walker.ReturnAliases; + return sqlAst.Walker.ReturnAliases; } } @@ -288,14 +289,14 @@ get { ErrorIfDML(); - IList<IASTNode> collectionFetches = ((QueryNode)_translator.SqlStatement).FromClause.GetCollectionFetches(); + IList<IASTNode> collectionFetches = ((QueryNode)sqlAst).FromClause.GetCollectionFetches(); return collectionFetches != null && collectionFetches.Count > 0; } } public bool IsManipulationStatement { - get { return _translator.SqlStatement.NeedsExecutor; } + get { return sqlAst.NeedsExecutor; } } /// <summary> @@ -344,9 +345,9 @@ HqlParseEngine parser = Parse(true); // PHASE 2 : Analyze the HQL AST, and produce an SQL AST. - HqlSqlWalker w = Analyze(parser, collectionRole); + var translator = Analyze(parser, collectionRole); - sqlAst = _translator.SqlStatement; + sqlAst = translator.SqlStatement; // at some point the generate phase needs to be moved out of here, // because a single object-level DML might spawn multiple SQL DML @@ -369,7 +370,7 @@ _generator = new HqlSqlGenerator(sqlAst, parser.Tokens, _factory); _generator.Generate(); - _queryLoader = new QueryLoader(this, _factory, w.SelectClause); + _queryLoader = new QueryLoader(this, _factory, sqlAst.Walker.SelectClause); } _compiled = true; @@ -439,13 +440,13 @@ } } - private HqlSqlWalker Analyze(HqlParseEngine parser, string collectionRole) + private HqlSqlTranslator Analyze(HqlParseEngine parser, string collectionRole) { - _translator = new HqlSqlTranslator(parser.Ast, parser.Tokens, this, _factory, tokenReplacements, + var translator = new HqlSqlTranslator(parser.Ast, parser.Tokens, this, _factory, tokenReplacements, collectionRole); - _translator.Translate(); + translator.Translate(); - return _translator.SqlStatement.Walker; + return translator; } private HqlParseEngine Parse(bool isFilter) @@ -460,7 +461,7 @@ private void ErrorIfDML() { - if (_translator.SqlStatement.NeedsExecutor) + if (sqlAst.NeedsExecutor) { throw new QueryExecutionRequestException("Not supported for DML operations", _hql); } @@ -481,20 +482,20 @@ private CommonTokenStream _tokens; private readonly bool _filter; private IASTNode _ast; - private ISessionFactoryImplementor _sfi; + private readonly ISessionFactoryImplementor _sfi; - public HqlParseEngine(string hql, bool filter, ISessionFactoryImplementor sfi) + public HqlParseEngine(string hql, bool filter, ISessionFactoryImplementor sfi) { _hql = hql; _filter = filter; - _sfi = sfi; + _sfi = sfi; } - public HqlParseEngine(IASTNode ast, ISessionFactoryImplementor sfi) - { - _sfi = sfi; - _ast = ast; - } + public HqlParseEngine(IASTNode ast, ISessionFactoryImplementor sfi) + { + _sfi = sfi; + _ast = ast; + } public string Hql { @@ -516,10 +517,10 @@ if (_ast == null) { // Parse the query string into an HQL AST. - HqlLexer lex = new HqlLexer(new CaseInsensitiveStringStream(_hql)); + var lex = new HqlLexer(new CaseInsensitiveStringStream(_hql)); _tokens = new CommonTokenStream(lex); - HqlParser parser = new HqlParser(_tokens); + var parser = new HqlParser(_tokens); parser.TreeAdaptor = new ASTTreeAdaptor(); parser.Filter = _filter; @@ -529,9 +530,9 @@ log.Debug("parse() - HQL: " + _hql); } - _ast = (IASTNode) parser.statement().Tree; + _ast = (IASTNode)parser.statement().Tree; - NodeTraverser walker = new NodeTraverser(new ConstantConverter(_sfi)); + var walker = new NodeTraverser(new ConstantConverter(_sfi)); walker.TraverseDepthFirst(_ast); //showHqlAst( hqlAst ); @@ -543,14 +544,14 @@ class ConstantConverter : IVisitationStrategy { private IASTNode dotRoot; - private ISessionFactoryImplementor _sfi; + private ISessionFactoryImplementor _sfi; - public ConstantConverter(ISessionFactoryImplementor sfi) - { - _sfi = sfi; - } + public ConstantConverter(ISessionFactoryImplementor sfi) + { + _sfi = sfi; + } - public void Visit(IASTNode node) + public void Visit(IASTNode node) { if (dotRoot != null) { @@ -578,7 +579,7 @@ object constant = ReflectHelper.GetConstantValue(expression, _sfi); - if ( constant != null ) + if (constant != null) { dotStructureRoot.ClearChildren(); dotStructureRoot.Type = HqlSqlWalker.JAVA_CONSTANT; @@ -619,18 +620,18 @@ get { return _resultAst; } } - public IStatement Translate() + public IStatement Translate() { if (_resultAst == null) { - HqlSqlWalkerTreeNodeStream nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); + var nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); nodes.TokenStream = _tokens; - - HqlSqlWalker hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); + + var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); // Transform the tree. - _resultAst = (IStatement) hqlSqlWalker.statement().Tree; + _resultAst = (IStatement)hqlSqlWalker.statement().Tree; /* if ( AST_LOG.isDebugEnabled() ) { @@ -659,7 +660,7 @@ public HqlSqlGenerator(IStatement ast, ITokenStream tokens, ISessionFactoryImplementor sfi) { - _ast = (IASTNode) ast; + _ast = (IASTNode)ast; _tokens = tokens; _sfi = sfi; } @@ -678,10 +679,10 @@ { if (_sql == null) { - CommonTreeNodeStream nodes = new CommonTreeNodeStream(_ast); + var nodes = new CommonTreeNodeStream(_ast); nodes.TokenStream = _tokens; - SqlGenerator gen = new SqlGenerator(_sfi, nodes); + var gen = new SqlGenerator(_sfi, nodes); //gen.TreeAdaptor = new ASTTreeAdaptor(); gen.statement(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-02 21:53:50
|
Revision: 4224 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4224&view=rev Author: fabiomaulo Date: 2009-05-02 21:53:39 +0000 (Sat, 02 May 2009) Log Message: ----------- NUnit2.5.0RC1 Modified Paths: -------------- trunk/nhibernate/lib/net/2.0/nunit.framework.dll trunk/nhibernate/lib/net/3.5/nunit.framework.dll trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs trunk/nhibernate/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs trunk/nhibernate/src/NHibernate.Test/Deletetransient/DeleteTransientEntityTest.cs trunk/nhibernate/src/NHibernate.Test/DriverTest/NullReferenceFixture.cs trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs trunk/nhibernate/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs trunk/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterConfig.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs trunk/nhibernate/src/NHibernate.Test/HQL/SqlCommentsFixture.cs trunk/nhibernate/src/NHibernate.Test/IdGen/Enhanced/SequenceStyleConfigUnitFixture.cs trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs trunk/nhibernate/src/NHibernate.Test/IdTest/IdentifierGeneratorFactoryFixture.cs trunk/nhibernate/src/NHibernate.Test/Legacy/CriteriaTest.cs trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs trunk/nhibernate/src/NHibernate.Test/MappingExceptions/MissingDefCtorFixture.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/ForeignKeyFixture.cs trunk/nhibernate/src/NHibernate.Test/NHAssert.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1326/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1413/PagingTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1635/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1675/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1694/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1710/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1713/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH280/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH350/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH496/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH593/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH606/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH712/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/OptimisticConcurrencyFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/Naturalid/Immutable/ImmutableNaturalIdFixture.cs trunk/nhibernate/src/NHibernate.Test/Naturalid/Mutable/MutableNaturalIdFixture.cs trunk/nhibernate/src/NHibernate.Test/Operations/AbstractOperationTestCase.cs trunk/nhibernate/src/NHibernate.Test/Operations/MergeFixture.cs trunk/nhibernate/src/NHibernate.Test/Pagination/PaginationFixture.cs trunk/nhibernate/src/NHibernate.Test/PropertyTest/BackFieldAccessorFixture.cs trunk/nhibernate/src/NHibernate.Test/PropertyTest/BasicSetterExceptionFixture.cs trunk/nhibernate/src/NHibernate.Test/PropertyTest/FieldSetterExceptionFixture.cs trunk/nhibernate/src/NHibernate.Test/PropertyTest/ReadonlyAccessorFixture.cs trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs trunk/nhibernate/src/NHibernate.Test/QueryTest/NamedParametersFixture.cs trunk/nhibernate/src/NHibernate.Test/QueryTest/PositionalParametersFixture.cs trunk/nhibernate/src/NHibernate.Test/QueryTest/QueryParametersFixture.cs trunk/nhibernate/src/NHibernate.Test/ReflectionOptimizerTest/LcgFixture.cs trunk/nhibernate/src/NHibernate.Test/SecondLevelCacheTest/QueryCacheFixture.cs trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTagFixture.cs trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs trunk/nhibernate/src/NHibernate.Test/TransactionTest/TransactionFixture.cs trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/CurrencyTypeFixture.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/AssemblyQualifiedTypeNameFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/IdentityMapFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/SequencedHashMapFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/SingletonEnumerableFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/SoftLimitMRUCacheFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/Assertions/ Modified: trunk/nhibernate/lib/net/2.0/nunit.framework.dll =================================================================== (Binary files differ) Modified: trunk/nhibernate/lib/net/3.5/nunit.framework.dll =================================================================== (Binary files differ) Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.BulkManipulation { Modified: trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using NHibernate.Bytecode; using NHibernate.Bytecode.Lightweight; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Bytecode.Lightweight { Modified: trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -2,7 +2,6 @@ using System.Collections; using System.Data; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Cascade { Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -161,7 +161,6 @@ } [Test] - [ExpectedException(typeof(HibernateConfigException))] public void CacheConfigurationForUnmappedClass() { string cfgString = @@ -173,11 +172,10 @@ </hibernate-configuration>"; Configuration cfg = new Configuration(); - cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null)); + Assert.Throws<HibernateConfigException>(()=>cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null))); } [Test] - [ExpectedException(typeof(HibernateConfigException))] public void CacheConfigurationForUnmappedCollection() { string cfgString = @@ -190,17 +188,16 @@ </hibernate-configuration>"; Configuration cfg = new Configuration(); - cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null)); + Assert.Throws<HibernateConfigException>(()=>cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null))); } [Test] - [ExpectedException(typeof(HibernateConfigException))] public void NoSessionFactoriesInConfiguration() { string cfgString = @"<?xml version='1.0' encoding='utf-8' ?><someElement />"; Configuration cfg = new Configuration(); - cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null)); + Assert.Throws<HibernateConfigException>(()=>cfg.Configure(new XmlTextReader(cfgString, XmlNodeType.Document, null))); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -11,7 +11,7 @@ [TestFixture] public class ConfigurationSchemaFixture { - [Test, ExpectedException(typeof(HibernateConfigException))] + [Test] public void InvalidConfig() { string xml = @@ -21,7 +21,7 @@ </hibernate-configuration>"; XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null); - HibernateConfiguration hc = new HibernateConfiguration(xtr); + Assert.Throws<HibernateConfigException>(()=>new HibernateConfiguration(xtr)); } [Test] @@ -52,7 +52,7 @@ Assert.AreEqual(hc.UseReflectionOptimizer, newhc.UseReflectionOptimizer); } - [Test, ExpectedException(typeof(HibernateConfigException))] + [Test] public void EmptyFactoryNotAllowed() { // session-factory omission not allowed out of App.config @@ -63,7 +63,7 @@ </hibernate-configuration>"; XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null); - HibernateConfiguration hc = new HibernateConfiguration(xtr); + Assert.Throws<HibernateConfigException>(()=> new HibernateConfiguration(xtr)); } [Test] @@ -148,7 +148,7 @@ (new MappingConfiguration("AAssembly", null)))); } - [Test, ExpectedException(typeof(HibernateConfigException))] + [Test] public void NotAllowedMappings() { string xml = @@ -160,7 +160,7 @@ </hibernate-configuration>"; XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null); - HibernateConfiguration hc = new HibernateConfiguration(xtr); + Assert.Throws<HibernateConfigException>(()=>new HibernateConfiguration(xtr)); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -5,7 +5,6 @@ using NHibernate.DomainModel; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.CfgTest { Modified: trunk/nhibernate/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -11,13 +11,12 @@ public class NamedConnectionStringFixture { [Test] - [ExpectedException(typeof(HibernateException), "Could not find named connection string MyConStr")] public void InvalidNamedConnectedStringThrows() { Dictionary<string, string> settings = new Dictionary<string, string>(); settings.Add(Environment.ConnectionStringName, "MyConStr"); ConnectionProvider cp = new MockConnectionProvider(); - cp.Configure(settings); + Assert.Throws<HibernateException>(()=>cp.Configure(settings), "Could not find named connection string MyConStr"); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -7,7 +7,6 @@ using NHibernate.Type; using NHibernate.Util; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Criteria { @@ -1434,14 +1433,14 @@ session.Close(); } - [Test, ExpectedException(typeof(QueryException))] + [Test] public void TypeMismatch() { using (ISession session = OpenSession()) { - session.CreateCriteria(typeof(Enrolment)) + Assert.Throws<QueryException>(() => session.CreateCriteria(typeof(Enrolment)) .Add(Expression.Eq("Student", 10)) // Type mismatch! - .List(); + .List()); } } Modified: trunk/nhibernate/src/NHibernate.Test/Deletetransient/DeleteTransientEntityTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Deletetransient/DeleteTransientEntityTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Deletetransient/DeleteTransientEntityTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,5 @@ using System.Collections; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Deletetransient { Modified: trunk/nhibernate/src/NHibernate.Test/DriverTest/NullReferenceFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DriverTest/NullReferenceFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/DriverTest/NullReferenceFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -24,28 +24,21 @@ /// but all properties were null. /// </remarks> /// TODO: I think this fixture is redundant now due to the QueryTest fixtures, just mark it so that it catches the new exception type for now - [Test, ExpectedException(typeof(QueryException))] + [Test] public void NoParameterNameNullReference() { ISession s = null; try { s = OpenSession(); - Console.WriteLine("about to run query"); IQuery q = s.CreateQuery("from Simple s where s.Name = :missing"); Assert.IsNotNull(q); q.List(); } - catch (ADOException ae) + catch (QueryException ae) { - Assert.IsTrue(ae.InnerException is QueryException); - Assert.IsTrue(ae.InnerException.Message.StartsWith("No value assigned to parameter")); + Assert.IsTrue(ae.Message.StartsWith("Not all named parameters have been set")); } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - throw; - } finally { s.Close(); Modified: trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Xml; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.EntityModeTest.Multi { Modified: trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Mapping; using NHibernate.Properties; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.EntityModeTest.Xml.Accessors { Modified: trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -5,7 +5,6 @@ using NHibernate.Criterion; using NHibernate.Transform; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using Environment=NHibernate.Cfg.Environment; namespace NHibernate.Test.EntityModeTest.Xml.Basic Modified: trunk/nhibernate/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -4,7 +4,6 @@ using NHibernate.Event; using NHibernate.Test.Events.Collections.Association.Bidirectional.ManyToMany; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Events.Collections { Modified: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -71,7 +71,6 @@ } [Test] - [ExpectedException(typeof(QueryException))] public void MisspelledPropertyWithNormalizedEntityPersister() { using (ISession session = factory.OpenSession()) @@ -79,7 +78,7 @@ CreateObjects(typeof(Multi), session); ICriterion expression = Expression.Eq("MisspelledProperty", DateTime.Now); - expression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>()); + Assert.Throws<QueryException>(() =>expression.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>())); } } } Modified: trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,5 @@ using NHibernate.Cfg; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Extendshbm { Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,5 @@ using System.Collections; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Extralazy { Modified: trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterConfig.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterConfig.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterConfig.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -55,7 +55,6 @@ [Test] - [ExpectedException(typeof(HibernateException))] public void TestFilterThrowsWithNoParameterSet() { Configuration cfg = new Configuration(); @@ -65,7 +64,7 @@ ISession session = factory.OpenSession(); IFilter filter = session.EnableFilter("LiveFilter"); - filter.Validate(); + Assert.Throws<HibernateException>(() => filter.Validate()); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.HQL.Ast { Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Dialect; using NHibernate.Dialect.Function; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Hql { @@ -186,7 +185,7 @@ } } - [Test, ExpectedException(typeof(QueryException))] + [Test] public void AggregateSumNH1100() { using (ISession s = OpenSession()) @@ -199,7 +198,7 @@ } using (ISession s = OpenSession()) { - s.CreateQuery("select distinct new SummaryItem(a.Description, sum(BodyWeight)) from Animal a").List<SummaryItem>(); + Assert.Throws<QueryException>(() => s.CreateQuery("select distinct new SummaryItem(a.Description, sum(BodyWeight)) from Animal a").List<SummaryItem>()); } } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/SqlCommentsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/SqlCommentsFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/HQL/SqlCommentsFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System.Collections; using NHibernate.Cfg; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.HQL { Modified: trunk/nhibernate/src/NHibernate.Test/IdGen/Enhanced/SequenceStyleConfigUnitFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdGen/Enhanced/SequenceStyleConfigUnitFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/IdGen/Enhanced/SequenceStyleConfigUnitFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System.Collections.Generic; using NHibernate.Id.Enhanced; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.IdGen.Enhanced { Modified: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,5 @@ using System.Collections; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.IdGen.NativeGuid { Modified: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Engine; using NHibernate.Id; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.IdGen.NativeGuid { Modified: trunk/nhibernate/src/NHibernate.Test/IdTest/IdentifierGeneratorFactoryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/IdentifierGeneratorFactoryFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/IdentifierGeneratorFactoryFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -12,10 +12,10 @@ /// caught with a bad class name passed in. /// </summary> [Test] - [ExpectedException(typeof(IdentifierGenerationException), "Could not interpret id generator strategy: Guid")] public void NonCreatableStrategy() { - IdentifierGeneratorFactory.Create("Guid", NHibernateUtil.Guid, null, new MsSql2000Dialect()); + Assert.Throws<IdentifierGenerationException>(() => IdentifierGeneratorFactory.Create("Guid", NHibernateUtil.Guid, null, new MsSql2000Dialect()), + "Could not interpret id generator strategy: Guid"); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/CriteriaTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/CriteriaTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/CriteriaTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -117,14 +117,13 @@ } [Test] - [ExpectedException(typeof(QueryException))] public void CriteriaTypeMismatch() { using (ISession s = OpenSession()) { - s.CreateCriteria(typeof(Master)) + Assert.Throws<QueryException>(() =>s.CreateCriteria(typeof(Master)) .Add(Expression.Like("Details", "SomeString")) - .List(); + .List()); } } @@ -144,14 +143,13 @@ } [Test] - [ExpectedException(typeof(QueryException))] public void CriteriaCompositeProperty() { using (ISession s = OpenSession()) { - s.CreateCriteria(typeof(Master)) + Assert.Throws<QueryException>(() =>s.CreateCriteria(typeof(Master)) .Add(Expression.Eq("Details.I", 10)) - .List(); + .List()); } } Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1985,24 +1985,22 @@ } [Test] - [ExpectedException(typeof(QueryException))] public void VerifyParameterNamedMissing() { using (ISession s = OpenSession()) { IQuery q = s.CreateQuery("select bar from Bar as bar where bar.X > :myX"); - q.List(); + Assert.Throws<QueryException>(() =>q.List()); } } [Test] - [ExpectedException(typeof(QueryException))] public void VerifyParameterPositionalMissing() { using (ISession s = OpenSession()) { IQuery q = s.CreateQuery("select bar from Bar as bar where bar.X > ?"); - q.List(); + Assert.Throws<QueryException>(() =>q.List()); } } @@ -2028,7 +2026,6 @@ } [Test] - [ExpectedException(typeof(QueryException))] public void VerifyParameterPositionalMissing2() { using (ISession s = OpenSession()) @@ -2036,7 +2033,7 @@ IQuery q = s.CreateQuery("select bar from Bar as bar where bar.String = ? or bar.String = ? or bar.String = ?"); q.SetParameter(0, "bull"); q.SetParameter(2, "shit"); - q.List(); + Assert.Throws<QueryException>(() =>q.List()); } } Modified: trunk/nhibernate/src/NHibernate.Test/MappingExceptions/MissingDefCtorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingExceptions/MissingDefCtorFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/MappingExceptions/MissingDefCtorFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -11,14 +11,14 @@ [TestFixture] public class MissingDefCtorFixture { - [Test, ExpectedException(typeof(InstantiationException))] + [Test] public void ClassMissingDefaultCtor() { // add a resource that doesn't exist string resource = "NHibernate.Test.MappingExceptions.MissingDefCtor.hbm.xml"; Configuration cfg = new Configuration(); - cfg.AddResource(resource, this.GetType().Assembly); - cfg.BuildSessionFactory(); + cfg.AddResource(resource, this.GetType().Assembly); + Assert.Throws<InstantiationException>(() =>cfg.BuildSessionFactory()); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/ForeignKeyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/ForeignKeyFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/ForeignKeyFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -7,7 +7,6 @@ public class ForeignKeyFixture { [Test] - [ExpectedException(typeof(FKUnmatchingColumnsException))] public void UnmatchingColumns() { Table primaryTable = new Table("pktable"); @@ -38,7 +37,7 @@ fk.Table = fkTable; fk.ReferencedTable = primaryTable; - fk.AlignColumns(); + Assert.Throws<FKUnmatchingColumnsException>(() => fk.AlignColumns()); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHAssert.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHAssert.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHAssert.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,8 @@ using System; -using NHibernate.Test.Assertions; +using System.Reflection; +using System.Text; using NUnit.Framework; +using System.Collections.Generic; namespace NHibernate.Test { @@ -15,7 +17,7 @@ public static void HaveSerializableAttribute(System.Type clazz, string message, params object[] args) { - Assert.DoAssert(new HaveSerializableAttributeAsserter(clazz, message, args)); + Assert.That(clazz, Has.Attribute<SerializableAttribute>(), message, args); } public static void InheritedAreMarkedSerializable(System.Type clazz) @@ -25,7 +27,20 @@ public static void InheritedAreMarkedSerializable(System.Type clazz, string message, params object[] args) { - Assert.DoAssert(new InheritedAreMarkedSerializable(clazz, message, args)); + var sb = new StringBuilder(); + int failedCount = 0; + Assembly nhbA = Assembly.GetAssembly(clazz); + IList<System.Type> types = ClassList(nhbA, clazz); + foreach (System.Type tp in types) + { + object[] atts = tp.GetCustomAttributes(typeof(SerializableAttribute), false); + if (atts.Length == 0) + { + sb.AppendLine(string.Format(" class {0} is not marked as Serializable", tp.FullName)); + failedCount++; + } + } + Assert.That(failedCount, Is.EqualTo(0)); } public static void IsSerializable(object obj) @@ -35,9 +50,23 @@ public static void IsSerializable(object obj, string message, params object[] args) { - Assert.DoAssert(new IsSerializable(obj, message, args)); + Assert.That(obj, Is.BinarySerializable, message, args); } #endregion + private static IList<System.Type> ClassList(Assembly assembly, System.Type type) + { + IList<System.Type> result = new List<System.Type>(); + if (assembly != null) + { + System.Type[] types = assembly.GetTypes(); + foreach (System.Type tp in types) + { + if (tp != type && type.IsAssignableFrom(tp) && !tp.IsInterface) + result.Add(tp); + } + } + return result; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -46,7 +46,6 @@ } [Test] - [ExpectedException(typeof(PropertyValueException))] public void TestErrorUsage() { using (ISession session = OpenSession()) @@ -59,7 +58,7 @@ fred.Address = flinstoneWay; wilma.Address = flinstoneWay; - session.Save(fred); + Assert.Throws<PropertyValueException>(() => session.Save(fred)); } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -30,13 +30,13 @@ } } - [Test, ExpectedException(typeof(ObjectDisposedException))] + [Test] public void ReconnectAfterClose() { using (ISession s = OpenSession()) { s.Close(); - s.Reconnect(); + Assert.Throws<ObjectDisposedException>(() => s.Reconnect()); } } @@ -56,11 +56,11 @@ } } - [Test, ExpectedException(typeof(ArgumentNullException))] + [Test] public void NullInterceptor() { IInterceptor nullInterceptor = null; - sessions.OpenSession(nullInterceptor).Close(); + Assert.Throws<ArgumentNullException>(() => sessions.OpenSession(nullInterceptor).Close()); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -5,7 +5,6 @@ using NHibernate.Driver; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using Environment=NHibernate.Cfg.Environment; Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -14,7 +14,6 @@ } [Test] - [ExpectedException(typeof(LazyInitializationException))] public void TestLazyLoad() { int parentId = 0; @@ -45,7 +44,7 @@ // Because it maintains logic to maintain the collection during the property set it should // tell NHibernate to skip the setter and access the field. If it doesn't, then throw // a LazyInitializationException. - int count = parent2.Children.Count; + Assert.Throws<LazyInitializationException>(() => { int count = parent2.Children.Count; }); } } finally Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using System.Text; using Iesi.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1289 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1326/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1326/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1326/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,7 @@ using System; using NHibernate.Cfg; using NHibernate.Event; +using NHibernate.Id; using NHibernate.Transaction; using NUnit.Framework; @@ -16,14 +17,12 @@ [Test] - [ExpectedException(typeof(InvalidOperationException), - "Disconnect cannot be called while a transaction is in progress.")] public void ShouldThrowIfCallingDisconnectInsideTransaction() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { - s.Disconnect(); + Assert.Throws<InvalidOperationException>(() => s.Disconnect(), "Disconnect cannot be called while a transaction is in progress."); tx.Commit(); } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1349 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1413/PagingTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1413/PagingTest.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1413/PagingTest.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System; using NHibernate.Criterion; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1413 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -2,7 +2,6 @@ using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1443 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System; using NHibernate.Proxy; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using System.Collections.Generic; namespace NHibernate.Test.NHSpecificTest.NH1464 Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,6 +1,5 @@ using System.Collections; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1488 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System.Collections.Generic; using NHibernate.Dialect; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1490 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -43,7 +43,6 @@ } } [Test] - [ExpectedException(typeof(QueryException))] public void CheckIfDetachedCriteriaCanBeUsedOnPropertyRestriction() { using (ISession session = OpenSession()) @@ -56,7 +55,7 @@ Property.ForName("Title").Eq("Spec"), Property.ForName("Person").Eq(detached) )); - IList<Document> results = criteria.List<Document>(); + Assert.Throws<QueryException>(() => criteria.List<Document>()); } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -66,32 +66,26 @@ } [Test] - [ExpectedException(typeof(NotSupportedException))] public void ThrowsExceptionWhenSqlQueryIsGiven() { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { ISQLQuery sqlQuery = session.CreateSQLQuery("select * from Document"); - IMultiQuery q = session - .CreateMultiQuery() - .Add(sqlQuery); - q.List(); + Assert.Throws<NotSupportedException>(() => session.CreateMultiQuery().Add(sqlQuery)); } } [Test] - [ExpectedException(typeof(NotSupportedException))] public void ThrowsExceptionWhenNamedSqlQueryIsGiven() { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { - IMultiQuery q = session + Assert.Throws<NotSupportedException>(() =>session .CreateMultiQuery() - .AddNamedQuery("SampleSqlQuery"); - q.List(); + .AddNamedQuery("SampleSqlQuery")); } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System.Collections.Generic; using NHibernate.Proxy; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1515 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Dialect; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1521 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1533 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -4,7 +4,6 @@ using System.Text; using NHibernate.Dialect; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1552 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1593 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using NHibernate.Util; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1608 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -2,7 +2,6 @@ using System.Collections.Generic; using NHibernate.Dialect; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1612 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1621 { @@ -32,7 +31,7 @@ var nums = session.CreateQuery("from Nums b where b.Sum > 4").List<Nums>(); - Assert.That(nums, Has.Count(1)); + Assert.That(nums.Count, Is.EqualTo(1)); Assert.That(nums[0].Sum, Is.EqualTo(7)); session.Delete("from Nums"); Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1632 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1635/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1635/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1635/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,7 +1,6 @@ using System.Text; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1635 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1640 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1675/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1675/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1675/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1675 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1693 { @@ -43,7 +42,7 @@ var list = session.CreateQuery(q1) .SetParameter("cat", 10) .List<Invoice>(); - Assert.That(list, Has.Count(2)); + Assert.That(list.Count, Is.EqualTo(2)); Assert.That(list[0].Num == 2 && list[0].Mode == "a"); Assert.That(list[1].Num == 4 && list[1].Mode == "a"); @@ -64,7 +63,7 @@ var list = session.CreateQuery(q1) .SetParameter("cat", 10) .List<Invoice>(); - Assert.That(list, Has.Count(2)); + Assert.That(list.Count, Is.EqualTo(2)); Assert.That(list[0].Num == 2 && list[0].Mode == "a"); Assert.That(list[1].Num == 4 && list[1].Mode == "a"); Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1694/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1694/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1694/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -2,7 +2,6 @@ using NHibernate.Criterion; using NHibernate.Dialect; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1694 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1710/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1710/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1710/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Engine; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1710 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1713/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1713/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1713/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -2,7 +2,6 @@ using NHibernate.Dialect; using NHibernate.Util; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1713 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -3,7 +3,6 @@ using NHibernate.Impl; using NUnit.Framework; using NHibernate.Util; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH1741 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH280/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH280/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH280/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -55,12 +55,12 @@ } } - [Test, ExpectedException(typeof(NHibernate.QueryException))] + [Test] public void TokenUnknow() { using (ISession s = OpenSession()) { - IList l = s.CreateQuery("select 123, notRecognized, f.Description from Foo f").List(); + Assert.Throws<QueryException>(() =>s.CreateQuery("select 123, notRecognized, f.Description from Foo f").List()); } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH350/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH350/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH350/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -13,7 +13,7 @@ // We pass an Int32 id to Load and expect an exception, since the class // uses Int64 ids. - [Test, ExpectedException(typeof(TypeMismatchException))] + [Test] public void Loading() { object parentId; @@ -31,9 +31,7 @@ { using (ISession session = OpenSession()) { - SecurityDomain aDomain = (SecurityDomain) session.Load(typeof(SecurityDomain), 1); - Assert.AreEqual("Name", aDomain.Name); - Assert.IsTrue(aDomain.ChildDomains.Count > 0); + Assert.Throws<TypeMismatchException>(() => session.Load(typeof(SecurityDomain), 1)); } } finally Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH496/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH496/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH496/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -36,8 +36,7 @@ using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { - obj = (WronglyMappedClass) s.Get(typeof(WronglyMappedClass), obj.Id); - Assert.AreEqual(10, obj.SomeInt); + Assert.Throws<PropertyAccessException>(() => s.Get(typeof(WronglyMappedClass), obj.Id)); t.Commit(); } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH593/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH593/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH593/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -6,16 +6,16 @@ [TestFixture] public class Fixture : BugTestCase { - [Test, ExpectedException(typeof(QueryException))] + [Test] public void Bug() { using (ISession session = OpenSession()) { User user = new User("test"); user.UserId = 10; - session.CreateCriteria(typeof(Blog)) + Assert.Throws<QueryException>(() => session.CreateCriteria(typeof(Blog)) .Add(Expression.In("Users", new User[] {user})) - .List(); + .List()); } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH606/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH606/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH606/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -26,13 +26,13 @@ [TestFixture] public class Fixture { - [Test, ExpectedException(typeof(MappingException))] + [Test] public void InvalidGenericMapping() { - ISessionFactory sf = new Configuration() - .AddResource(typeof (Fixture).Namespace + ".Mapping.hbm.xml", typeof (Fixture).Assembly) - .BuildSessionFactory(); - sf.Close(); + Assert.Throws<MappingException>( + () => + new Configuration().AddResource(typeof (Fixture).Namespace + ".Mapping.hbm.xml", typeof (Fixture).Assembly). + BuildSessionFactory()); } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs 2009-05-02 05:10:00 UTC (rev 4223) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs 2009-05-02 21:53:39 UTC (rev 4224) @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.NHSpecificTest.NH662 { Modified: trunk/nhiber... [truncated message content] |
From: <fab...@us...> - 2009-05-02 05:10:05
|
Revision: 4223 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4223&view=rev Author: fabiomaulo Date: 2009-05-02 05:10:00 +0000 (Sat, 02 May 2009) Log Message: ----------- First test for executable HQL passed Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -6,9 +6,11 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; +using NHibernate.SqlTypes; namespace NHibernate.Hql.Ast.ANTLR.Exec { @@ -17,18 +19,19 @@ { private readonly IQueryable persister; private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); - private SqlString sql; + private readonly SqlString sql; - public BasicExecutor(HqlSqlWalker walker, IQueryable persister) : base(walker, log) + public BasicExecutor(IStatement statement, ITokenStream tokenStream, IQueryable persister) + : base(statement.Walker, log) { this.persister = persister; try { + var generator = new HqlSqlGenerator(statement, tokenStream, Factory); + generator.Generate(); - //SqlGenerator gen = new SqlGenerator(Factory); - //gen.statement(walker.getAST()); - //sql = gen.GetSQL(); - //gen.ParseErrorHandler.ThrowQueryException(); + sql = generator.Sql; + Parameters = generator.CollectionParameters; } catch (RecognitionException e) { @@ -36,6 +39,8 @@ } } + protected IList<IParameterSpecification> Parameters{get;private set;} + protected ISessionFactoryImplementor Factory { get @@ -60,8 +65,13 @@ { try { - //st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes); - IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + var parameterTypes = new List<SqlType>(Parameters.Count); + foreach (var parameterSpecification in Parameters) + { + parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); + } + st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); + IEnumerator<IParameterSpecification> paramSpecifications = Parameters.GetEnumerator(); int pos = 1; while (paramSpecifications.MoveNext()) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -165,7 +165,7 @@ void PostProcessDelete(IASTNode delete) { - throw new NotImplementedException(); // DML + PostProcessDML((DeleteStatement)delete); } void PostProcessInsert(IASTNode insert) @@ -173,6 +173,24 @@ throw new NotImplementedException(); // DML } + private void PostProcessDML(IRestrictableStatement statement) + { + statement.FromClause.Resolve(); + + var fromElement = (FromElement)statement.FromClause.GetFromElements()[0]; + IQueryable persister = fromElement.Queryable; + // Make #@%$^#^&# sure no alias is applied to the table name + fromElement.Text = persister.TableName; + + // append any filter fragments; the EMPTY_MAP is used under the assumption that + // currently enabled filters should not affect this process + if (persister.DiscriminatorType != null) + { + new SyntheticAndFactory(this) + .AddDiscriminatorWhereFragment(statement, persister, new CollectionHelper.EmptyMapClass<string, IFilter>(), fromElement.TableAlias); + } + } + void AfterStatementCompletion(string statementName) { if (log.IsDebugEnabled) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -166,9 +166,18 @@ public int ExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session) { - throw new System.NotImplementedException(); // DML + ErrorIfSelect(); + return statementExecutor.Execute(queryParameters, session); } + private void ErrorIfSelect() + { + if (!sqlAst.NeedsExecutor) + { + throw new QueryExecutionRequestException("Not supported for select queries:", _hql); + } + } + public NHibernate.Loader.Loader Loader { get { return _queryLoader; } @@ -229,17 +238,14 @@ { get { - List<string> list = new List<string>(); + var list = new List<string>(); if (IsManipulationStatement) { - throw new NotImplementedException(); // DML - /* - String[] sqlStatements = statementExecutor.getSqlStatements(); - for (int i = 0; i < sqlStatements.length; i++) + SqlString[] sqlStatements = statementExecutor.SqlStatements; + foreach (var sqlStatement in sqlStatements) { - list.Add(sqlStatements[i]); + list.Add(sqlStatement.ToString()); } - */ } else { @@ -340,7 +346,7 @@ // PHASE 2 : Analyze the HQL AST, and produce an SQL AST. HqlSqlWalker w = Analyze(parser, collectionRole); - sqlAst = (IStatement)w.statement().Tree; + sqlAst = _translator.SqlStatement; // at some point the generate phase needs to be moved out of here, // because a single object-level DML might spawn multiple SQL DML @@ -353,14 +359,14 @@ // QueryLoader currently even has a dependency on this at all; does // it need it? Ideally like to see the walker itself given to the delegates directly... - if (_translator.SqlStatement.NeedsExecutor) + if (sqlAst.NeedsExecutor) { - statementExecutor = BuildAppropriateStatementExecutor(w); + statementExecutor = BuildAppropriateStatementExecutor(sqlAst); } else { // PHASE 3 : Generate the SQL. - _generator = new HqlSqlGenerator(_translator.SqlStatement, parser.Tokens, _factory); + _generator = new HqlSqlGenerator(sqlAst, parser.Tokens, _factory); _generator.Generate(); _queryLoader = new QueryLoader(this, _factory, w.SelectClause); @@ -387,8 +393,9 @@ _enabledFilters = null; //only needed during compilation phase... } - private IStatementExecutor BuildAppropriateStatementExecutor(HqlSqlWalker walker) + private IStatementExecutor BuildAppropriateStatementExecutor(IStatement statement) { + HqlSqlWalker walker = statement.Walker; if (walker.StatementType == HqlSqlWalker.DELETE) { FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); @@ -400,7 +407,7 @@ } else { - return new BasicExecutor(walker, persister); + return new BasicExecutor(statement, _parser.Tokens, persister); } } else if (walker.StatementType == HqlSqlWalker.UPDATE) @@ -417,7 +424,7 @@ } else { - return new BasicExecutor(walker, persister); + return new BasicExecutor(statement, _parser.Tokens, persister); } } else if (walker.StatementType == HqlSqlWalker.INSERT) @@ -645,12 +652,12 @@ private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlGenerator)); private readonly IASTNode _ast; - private readonly CommonTokenStream _tokens; + private readonly ITokenStream _tokens; private readonly ISessionFactoryImplementor _sfi; private SqlString _sql; private IList<IParameterSpecification> _parameters; - public HqlSqlGenerator(IStatement ast, CommonTokenStream tokens, ISessionFactoryImplementor sfi) + public HqlSqlGenerator(IStatement ast, ITokenStream tokens, ISessionFactoryImplementor sfi) { _ast = (IASTNode) ast; _tokens = tokens; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -273,7 +273,17 @@ return _children[index]; } - public void SetChild(int index, IASTNode newChild) + public IASTNode GetFirstChild() + { + return GetChild(0); + } + + public void SetFirstChild(IASTNode newChild) + { + SetChild(0, newChild); + } + + public void SetChild(int index, IASTNode newChild) { if ((_children == null) || _children.Count <= index) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -360,5 +360,23 @@ { return "FromClause{" + "level=" + _level + "}"; } + + public virtual void Resolve() + { + // Make sure that all from elements registered with this FROM clause are actually in the AST. + var iter = (new ASTIterator(GetFirstChild())).GetEnumerator(); + var childrenInTree = new HashedSet<IASTNode>(); + while (iter.MoveNext()) + { + childrenInTree.Add(iter.Current); + } + foreach (var fromElement in _fromElements) + { + if (!childrenInTree.Contains(fromElement)) + { + throw new SemanticException("Element not in AST: " + fromElement); + } + } + } } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -33,8 +33,7 @@ ret = new SqlNode(payload); break; case HqlSqlWalker.DELETE: - //return DeleteStatement.class; - ret = new SqlNode(payload); + ret = new DeleteStatement(payload); break; case HqlSqlWalker.INSERT: //return InsertStatement.class; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -17,7 +17,9 @@ IASTNode Parent { get; set; } IASTNode NextSibling { get; } IASTNode GetChild(int index); - void SetChild(int index, IASTNode newChild); + IASTNode GetFirstChild(); + void SetFirstChild(IASTNode newChild); + void SetChild(int index, IASTNode newChild); IASTNode AddChild(IASTNode childNode); IASTNode InsertChild(int index, IASTNode child); IASTNode AddSibling(IASTNode newSibling); @@ -30,7 +32,7 @@ // TODO - not sure we need this... IToken Token { get; } - + string ToStringTree(); } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -13,14 +13,16 @@ [CLSCompliant(false)] public class ASTIterator : IEnumerable<IASTNode> { + private readonly Stack<IASTNode> _stack = new Stack<IASTNode>(); private IASTNode _current; - private readonly Stack<IASTNode> _stack = new Stack<IASTNode>(); public ASTIterator(IASTNode tree) { _current = tree; } + #region IEnumerable<IASTNode> Members + public IEnumerator<IASTNode> GetEnumerator() { Down(); @@ -45,17 +47,20 @@ } } - private void Down() { - while ( _current != null && _current.ChildCount > 0) + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + private void Down() + { + while (_current != null && _current.ChildCount > 0) { _stack.Push(_current); _current = _current.GetChild(0); } } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -4,6 +4,11 @@ namespace NHibernate.Hql.Ast.ANTLR.Util { + /// <summary> + /// Filters nodes in/out of a tree. + /// </summary> + /// <param name="node">The node to check.</param> + /// <returns>true to keep the node, false if the node should be filtered out.</returns> [CLSCompliant(false)] public delegate bool FilterPredicate(IASTNode node); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -1,11 +1,12 @@ using System; -using Antlr.Runtime.Tree; using log4net; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; +using NHibernate.Persister.Entity; +using System.Collections.Generic; namespace NHibernate.Hql.Ast.ANTLR.Util { @@ -143,5 +144,45 @@ { return _hqlSqlWalker.ASTFactory.CreateNode(tokenType, text); } + + public virtual void AddDiscriminatorWhereFragment(IRestrictableStatement statement, IQueryable persister, IDictionary<string, IFilter> enabledFilters, string alias) + { + string whereFragment = persister.FilterFragment(alias, enabledFilters).Trim(); + if (string.Empty.Equals(whereFragment)) + { + return; + } + if (whereFragment.StartsWith("and")) + { + whereFragment = whereFragment.Substring(4); + } + + // Need to parse off the column qualifiers; this is assuming (which is true as of now) + // that this is only used from update and delete HQL statement parsing + whereFragment = StringHelper.Replace(whereFragment, persister.GenerateFilterConditionAlias(alias) + ".", ""); + + // Note: this simply constructs a "raw" SQL_TOKEN representing the + // where fragment and injects this into the tree. This "works"; + // however it is probably not the best long-term solution. + // + // At some point we probably want to apply an additional grammar to + // properly tokenize this where fragment into constituent parts + // focused on the operators embedded within the fragment. + IASTNode discrimNode = Create(HqlSqlWalker.SQL_TOKEN, whereFragment); + + if (statement.WhereClause.ChildCount == 0) + { + statement.WhereClause.SetFirstChild(discrimNode); + } + else + { + IASTNode and = Create(HqlSqlWalker.AND, "{and}"); + IASTNode currentFirstChild = statement.WhereClause.GetFirstChild(); + and.SetFirstChild(discrimNode); + and.AddChild(currentFirstChild); + statement.WhereClause.SetFirstChild(and); + } + } + } } Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -6,7 +6,7 @@ [TestFixture] public class HqlBulkOperations: BaseFixture { - [Test, Ignore("Not supported yet.")] + [Test] public void SimpleDelete() { using (var s = OpenSession()) Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-05-02 05:10:00 UTC (rev 4223) @@ -3,7 +3,7 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.BulkManipulation"> - <class name="SimpleClass"> + <class name="SimpleClass" table="TSIMPLE"> <id type="int"> <generator class="native" /> </id> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-01 14:55:38
|
Revision: 4222 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4222&view=rev Author: fabiomaulo Date: 2009-05-01 14:55:28 +0000 (Fri, 01 May 2009) Log Message: ----------- Refactoring: - Moved Parameters classes to NH namespace (as in Hb) - Removed TODO.cs (the last method was moved in StringHelper) - Moved NullableDictionary to default util (it need some investigation about its real usage) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs trunk/nhibernate/src/NHibernate/Util/StringHelper.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Param/ trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -6,7 +6,7 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,16 +1,17 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime.Tree; using Iesi.Collections.Generic; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; +using NHibernate.Util; namespace NHibernate.Hql.Ast.ANTLR { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,14 +1,13 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; -using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Impl; using NHibernate.Loader; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -8,9 +8,9 @@ using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Exec; using NHibernate.Hql.Ast.ANTLR.Loader; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,9 +1,8 @@ -using System; +using System; using System.Collections.Generic; using NHibernate.Dialect.Function; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Tree; -using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Hql.Util; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,12 +1,12 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using Antlr.Runtime; using Antlr.Runtime.Tree; using NHibernate.Dialect.Function; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; using NHibernate.SqlCommand; namespace NHibernate.Hql.Ast.ANTLR Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,19 +0,0 @@ -using System; - -namespace NHibernate.Hql.Ast.ANTLR -{ - public class LoadQueryInfluencers - { - public static string[] ParseFilterParameterName(string filterParameterName) - { - int dot = filterParameterName.IndexOf("."); - if (dot <= 0) - { - throw new ArgumentException("Invalid filter-parameter name format", "filterParameterName"); - } - string filterName = filterParameterName.Substring(0, dot); - string parameterName = filterParameterName.Substring(dot + 1); - return new[] { filterName, parameterName }; - } - } -} Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,7 +1,7 @@ -using System; +using System; using Antlr.Runtime; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Type; using NHibernate.Util; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; using Iesi.Collections.Generic; using log4net; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Util; namespace NHibernate.Hql.Ast.ANTLR.Tree { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using Antlr.Runtime; using log4net; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -3,7 +3,7 @@ using System.Text; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,4 +1,4 @@ -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; namespace NHibernate.Hql.Ast.ANTLR.Tree { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; using Antlr.Runtime.Tree; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,8 +1,8 @@ -using System; +using System; using System.Text; using Antlr.Runtime; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,7 +1,7 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.SqlCommand; namespace NHibernate.Hql.Ast.ANTLR.Tree Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,13 +1,13 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Text; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Classic; using NHibernate.Impl; +using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -180,7 +180,7 @@ if ( token.StartsWith( ParserHelper.HqlVariablePrefix ) ) { string filterParameterName = token.Substring( 1 ); - string[] parts = LoadQueryInfluencers.ParseFilterParameterName( filterParameterName ); + string[] parts = StringHelper.ParseFilterParameterName( filterParameterName ); FilterImpl filter = ( FilterImpl ) walker.EnabledFilters[parts[0]]; Object value = filter.GetParameter( parts[1] ); IType type = filter.FilterDefinition.GetParameterType( parts[1] ); Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,230 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace NHibernate.Hql.Ast.ANTLR.Util -{ - public class NullableDictionary<TKey, TValue> : IDictionary<TKey, TValue> - where TKey : class - { - private TValue _nullValue; - private bool _gotNullValue; - private readonly Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); - - public bool ContainsKey(TKey key) - { - if (key == null) - { - return _gotNullValue; - } - else - { - return _dict.ContainsKey(key); - } - } - - public void Add(TKey key, TValue value) - { - if (key == null) - { - _nullValue = value; - } - else - { - _dict[key] = value; - } - } - - public bool Remove(TKey key) - { - if (key == null) - { - if (_gotNullValue) - { - _nullValue = default(TValue); - _gotNullValue = false; - return true; - } - else - { - return false; - } - } - else - { - return _dict.Remove(key); - } - } - - public bool TryGetValue(TKey key, out TValue value) - { - if (key == null) - { - if (_gotNullValue) - { - value = _nullValue; - return true; - } - else - { - value = default(TValue); - return false; - } - } - else - { - return _dict.TryGetValue(key, out value); - } - } - - public TValue this[TKey key] - { - get - { - if (key == null) - { - return _nullValue; - } - else - { - TValue ret; - - _dict.TryGetValue(key, out ret); - - return ret; - } - } - set - { - if (key == null) - { - _nullValue = value; - _gotNullValue = true; - } - else - { - _dict[key] = value; - } - } - } - - public ICollection<TKey> Keys - { - get - { - if (_gotNullValue) - { - List<TKey> keys = new List<TKey>(_dict.Keys); - keys.Add(null); - return keys; - } - else - { - return _dict.Keys; - } - } - } - - public ICollection<TValue> Values - { - get - { - if (_gotNullValue) - { - List<TValue> values = new List<TValue>(_dict.Values); - values.Add(_nullValue); - return values; - } - else - { - return _dict.Values; - } - } - } - - public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() - { - foreach (KeyValuePair<TKey, TValue> kvp in _dict) - { - yield return kvp; - } - - if (_gotNullValue) - { - yield return new KeyValuePair<TKey, TValue>(null, _nullValue); - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void Add(KeyValuePair<TKey, TValue> item) - { - if (item.Key == null) - { - _nullValue = item.Value; - _gotNullValue = true; - } - else - { - _dict.Add(item.Key, item.Value); - } - } - - public void Clear() - { - _dict.Clear(); - _nullValue = default(TValue); - _gotNullValue = false; - } - - public bool Contains(KeyValuePair<TKey, TValue> item) - { - TValue val = default(TValue); - - if (TryGetValue(item.Key, out val)) - { - if (Equals(item.Value, val)) - { - return true; - } - return false; - } - else - { - return false; - } - } - - public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) - { - throw new System.NotImplementedException(); - } - - public bool Remove(KeyValuePair<TKey, TValue> item) - { - throw new System.NotImplementedException(); - } - - public int Count - { - get - { - if (_gotNullValue) - { - return _dict.Count + 1; - } - else - { - return _dict.Count; - } - } - } - - public bool IsReadOnly - { - get { return false; } - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,8 +1,8 @@ -using System; +using System; using Antlr.Runtime.Tree; using log4net; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:55:28 UTC (rev 4222) @@ -496,21 +496,20 @@ <Compile Include="Hql\Ast\ANTLR\InvalidWithClauseException.cs" /> <Compile Include="Hql\Ast\ANTLR\IParseErrorHandler.cs" /> <Compile Include="Hql\Ast\ANTLR\Loader\QueryLoader.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\AbstractExplicitParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\CollectionFilterKeyParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\DynamicFilterParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\IExplicitParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\IParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\NamedParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\ParameterTranslationsImpl.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\PositionalParameterSpecification.cs" /> + <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> + <Compile Include="Param\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> + <Compile Include="Param\CollectionFilterKeyParameterSpecification.cs" /> + <Compile Include="Param\DynamicFilterParameterSpecification.cs" /> + <Compile Include="Param\IExplicitParameterSpecification.cs" /> + <Compile Include="Param\IParameterSpecification.cs" /> + <Compile Include="Param\NamedParameterSpecification.cs" /> + <Compile Include="Param\ParameterTranslationsImpl.cs" /> + <Compile Include="Param\PositionalParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\QuerySyntaxException.cs" /> <Compile Include="Hql\Ast\ANTLR\QueryTranslatorImpl.cs" /> <Compile Include="Hql\Ast\ANTLR\SemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\SessionFactoryHelperExtensions.cs" /> <Compile Include="Hql\Ast\ANTLR\SqlGenerator.cs" /> - <Compile Include="Hql\Ast\ANTLR\TODO.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractNullnessCheckNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractRestrictableStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractSelectExpression.cs" /> @@ -585,7 +584,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\JoinProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> - <Compile Include="Hql\Ast\ANTLR\Util\NullableDictionary.cs" /> + <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> <Compile Include="Id\TriggerIdentityGenerator.cs" /> Modified: trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/AbstractExplicitParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,13 +2,8 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { - /** - * Convenience base class for explicitly defined query parameters. - * - * @author Steve Ebersole - */ public abstract class AbstractExplicitParameterSpecification : IExplicitParameterSpecification { private readonly int _sourceLine; @@ -44,4 +39,4 @@ public abstract string RenderDisplayInfo(); public abstract int Bind(IDbCommand statement, QueryParameters qp, ISessionImplementor session, int position); } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/AggregatedIndexCollectionSelectorParameterSpecifications.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -4,7 +4,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { public class AggregatedIndexCollectionSelectorParameterSpecifications : IParameterSpecification { @@ -49,4 +49,4 @@ return buffer.ToString(); } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/CollectionFilterKeyParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -3,7 +3,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { class CollectionFilterKeyParameterSpecification : IParameterSpecification { @@ -25,10 +25,10 @@ } public int Bind( - IDbCommand statement, - QueryParameters qp, - ISessionImplementor session, - int position) + IDbCommand statement, + QueryParameters qp, + ISessionImplementor session, + int position) { object value = qp.PositionalParameterValues[_queryParameterPosition]; _keyType.NullSafeSet(statement, value, position, session); @@ -46,4 +46,4 @@ return "collection-filter-key=" + _collectionRole; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/DynamicFilterParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -4,7 +4,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { public class DynamicFilterParameterSpecification : IParameterSpecification { @@ -19,9 +19,9 @@ /// <param name="parameterName">The name of the parameter</param> /// <param name="definedParameterType">The paremeter type specified on the filter metadata</param> public DynamicFilterParameterSpecification( - string filterName, - string parameterName, - IType definedParameterType) + string filterName, + string parameterName, + IType definedParameterType) { _filterName = filterName; _parameterName = parameterName; @@ -64,4 +64,4 @@ return "dynamic-filter={filterName=" + _filterName + ",paramName=" + _parameterName + "}"; } } -} +} \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,21 +0,0 @@ -namespace NHibernate.Hql.Ast.ANTLR.Parameters -{ - /// <summary> - /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement - /// (HQL or native-SQL). - /// Author: Steve Ebersole - /// Ported by: Steve Strong - /// </summary> - public interface IExplicitParameterSpecification : IParameterSpecification - { - /// <summary> - /// Retrieves the line number on which this parameter occurs in the source query. - /// </summary> - int SourceLine { get; } - - /// <summary> - /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. - /// </summary> - int SourceColumn { get; } - } -} Copied: trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs (from rev 4221, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -0,0 +1,21 @@ +namespace NHibernate.Param +{ + /// <summary> + /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement + /// (HQL or native-SQL). + /// Author: Steve Ebersole + /// Ported by: Steve Strong + /// </summary> + public interface IExplicitParameterSpecification : IParameterSpecification + { + /// <summary> + /// Retrieves the line number on which this parameter occurs in the source query. + /// </summary> + int SourceLine { get; } + + /// <summary> + /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. + /// </summary> + int SourceColumn { get; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Maintains information relating to parameters which need to get bound into a @@ -34,4 +34,4 @@ /// <returns>The displayable info</returns> string RenderDisplayInfo(); } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/NamedParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using System.Data; using NHibernate.Engine; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Parameter bind specification for an explicit named parameter. @@ -51,5 +51,4 @@ get { return _name; } } } - -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ParameterTranslationsImpl.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Hql; using NHibernate.Type; using NHibernate.Util; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Defines the information available for parameters encountered during @@ -46,13 +46,13 @@ else { // don't care about other param types here, just those explicitly user-defined... - // Steve Strong Note: The original Java does not do this decrement; it increments i for - // every parameter type. However, within the Loader.GetParameterTypes() method, this introduces - // nulls into the paramTypeList array, which in turn causes Loader.ConvertITypesToSqlTypes() to crash - // with a null dereference. An alternative fix is to change the Loader to handle the null. I'm - // not sure which fix is the most appropriate. - // Legacy.FumTest.CompositeIDQuery() shows the bug if you remove the decrement below... - i--; + // Steve Strong Note: The original Java does not do this decrement; it increments i for + // every parameter type. However, within the Loader.GetParameterTypes() method, this introduces + // nulls into the paramTypeList array, which in turn causes Loader.ConvertITypesToSqlTypes() to crash + // with a null dereference. An alternative fix is to change the Loader to handle the null. I'm + // not sure which fix is the most appropriate. + // Legacy.FumTest.CompositeIDQuery() shows the bug if you remove the decrement below... + i--; } i++; @@ -67,22 +67,22 @@ } } - public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) - { - foreach (ParameterInfo entry in _namedParameters.Values) - { - for (int index = 0; index < entry.SqlLocations.Length; index++) - { - if (entry.SqlLocations[index] >= existingParameterLocation) - { - entry.SqlLocations[index]++; - } - } - } - } - } + public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) + { + foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + { + foreach (ParameterInfo entry in _namedParameters.Values) + { + for (int index = 0; index < entry.SqlLocations.Length; index++) + { + if (entry.SqlLocations[index] >= existingParameterLocation) + { + entry.SqlLocations[index]++; + } + } + } + } + } public int GetOrdinalParameterSqlLocation(int ordinalPosition) { @@ -164,4 +164,4 @@ get { return _expectedType; } } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/PositionalParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using System.Data; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Parameter bind specification for an explicit positional (or ordinal) parameter. @@ -54,4 +54,4 @@ get { return _hqlPosition; } } } -} +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs (from rev 4219, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -0,0 +1,230 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NHibernate.Util +{ + public class NullableDictionary<TKey, TValue> : IDictionary<TKey, TValue> + where TKey : class + { + private TValue _nullValue; + private bool _gotNullValue; + private readonly Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); + + public bool ContainsKey(TKey key) + { + if (key == null) + { + return _gotNullValue; + } + else + { + return _dict.ContainsKey(key); + } + } + + public void Add(TKey key, TValue value) + { + if (key == null) + { + _nullValue = value; + } + else + { + _dict[key] = value; + } + } + + public bool Remove(TKey key) + { + if (key == null) + { + if (_gotNullValue) + { + _nullValue = default(TValue); + _gotNullValue = false; + return true; + } + else + { + return false; + } + } + else + { + return _dict.Remove(key); + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (key == null) + { + if (_gotNullValue) + { + value = _nullValue; + return true; + } + else + { + value = default(TValue); + return false; + } + } + else + { + return _dict.TryGetValue(key, out value); + } + } + + public TValue this[TKey key] + { + get + { + if (key == null) + { + return _nullValue; + } + else + { + TValue ret; + + _dict.TryGetValue(key, out ret); + + return ret; + } + } + set + { + if (key == null) + { + _nullValue = value; + _gotNullValue = true; + } + else + { + _dict[key] = value; + } + } + } + + public ICollection<TKey> Keys + { + get + { + if (_gotNullValue) + { + List<TKey> keys = new List<TKey>(_dict.Keys); + keys.Add(null); + return keys; + } + else + { + return _dict.Keys; + } + } + } + + public ICollection<TValue> Values + { + get + { + if (_gotNullValue) + { + List<TValue> values = new List<TValue>(_dict.Values); + values.Add(_nullValue); + return values; + } + else + { + return _dict.Values; + } + } + } + + public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() + { + foreach (KeyValuePair<TKey, TValue> kvp in _dict) + { + yield return kvp; + } + + if (_gotNullValue) + { + yield return new KeyValuePair<TKey, TValue>(null, _nullValue); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair<TKey, TValue> item) + { + if (item.Key == null) + { + _nullValue = item.Value; + _gotNullValue = true; + } + else + { + _dict.Add(item.Key, item.Value); + } + } + + public void Clear() + { + _dict.Clear(); + _nullValue = default(TValue); + _gotNullValue = false; + } + + public bool Contains(KeyValuePair<TKey, TValue> item) + { + TValue val = default(TValue); + + if (TryGetValue(item.Key, out val)) + { + if (Equals(item.Value, val)) + { + return true; + } + return false; + } + else + { + return false; + } + } + + public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) + { + throw new System.NotImplementedException(); + } + + public bool Remove(KeyValuePair<TKey, TValue> item) + { + throw new System.NotImplementedException(); + } + + public int Count + { + get + { + if (_gotNullValue) + { + return _dict.Count + 1; + } + else + { + return _dict.Count; + } + } + } + + public bool IsReadOnly + { + get { return false; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Util/StringHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -722,5 +722,17 @@ } return identifier; } + + public static string[] ParseFilterParameterName(string filterParameterName) + { + int dot = filterParameterName.IndexOf("."); + if (dot <= 0) + { + throw new ArgumentException("Invalid filter-parameter name format; the name should be a property path.", "filterParameterName"); + } + string filterName = filterParameterName.Substring(0, dot); + string parameterName = filterParameterName.Substring(dot + 1); + return new[] { filterName, parameterName }; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-01 14:09:07
|
Revision: 4221 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4221&view=rev Author: fabiomaulo Date: 2009-05-01 14:09:04 +0000 (Fri, 01 May 2009) Log Message: ----------- renamed file Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-04-30 23:44:59 UTC (rev 4220) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-05-01 14:09:04 UTC (rev 4221) @@ -1,21 +0,0 @@ -namespace NHibernate.Hql.Ast.ANTLR.Parameters -{ - /// <summary> - /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement - /// (HQL or native-SQL). - /// Author: Steve Ebersole - /// Ported by: Steve Strong - /// </summary> - public interface IExplicitParameterSpecification : IParameterSpecification - { - /// <summary> - /// Retrieves the line number on which this parameter occurs in the source query. - /// </summary> - int SourceLine { get; } - - /// <summary> - /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. - /// </summary> - int SourceColumn { get; } - } -} Copied: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs (from rev 4219, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs 2009-05-01 14:09:04 UTC (rev 4221) @@ -0,0 +1,21 @@ +namespace NHibernate.Hql.Ast.ANTLR.Parameters +{ + /// <summary> + /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement + /// (HQL or native-SQL). + /// Author: Steve Ebersole + /// Ported by: Steve Strong + /// </summary> + public interface IExplicitParameterSpecification : IParameterSpecification + { + /// <summary> + /// Retrieves the line number on which this parameter occurs in the source query. + /// </summary> + int SourceLine { get; } + + /// <summary> + /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. + /// </summary> + int SourceColumn { get; } + } +} Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 23:44:59 UTC (rev 4220) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:09:04 UTC (rev 4221) @@ -500,7 +500,7 @@ <Compile Include="Hql\Ast\ANTLR\Parameters\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\CollectionFilterKeyParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\DynamicFilterParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\ExplicitParameterSpecification.cs" /> + <Compile Include="Hql\Ast\ANTLR\Parameters\IExplicitParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\IParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\NamedParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\ParameterTranslationsImpl.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-30 23:45:02
|
Revision: 4220 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4220&view=rev Author: fabiomaulo Date: 2009-04-30 23:44:59 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Minor (removed TODO) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/LockMode.cs Modified: trunk/nhibernate/src/NHibernate/LockMode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/LockMode.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/LockMode.cs 2009-04-30 23:44:59 UTC (rev 4220) @@ -128,8 +128,5 @@ { return hashcode; } - - //TODO: need to implement .NET equivalent of readResolve - believe it is - // the IObjectReference interface... } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-30 23:41:34
|
Revision: 4219 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4219&view=rev Author: fabiomaulo Date: 2009-04-30 23:40:57 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Removing compilation Warnings about CLS compliant and some other about Equals+GetHashCode Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IBinaryOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IResolvableNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IRestrictableStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ISelectExpression.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IUnaryOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IsNotNullLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IsNullLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/LiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/OrderByClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UnaryArithmeticNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UnaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTAppender.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTUtil.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ColumnHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/IVisitationStrategy.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NodeTraverser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/PathHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate/LockMode.cs trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ /// Look ahead for tokenizing is all lowercase, whereas the original case of an input stream is preserved. /// Copied from http://www.antlr.org/wiki/pages/viewpage.action?pageId=1782 ///</summary> + [CLSCompliant(false)] public class CaseInsensitiveStringStream : ANTLRStringStream { public CaseInsensitiveStringStream(char[] data, int numberOfActualCharsInArray) : base(data, numberOfActualCharsInArray) { } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Text; using Antlr.Runtime; using log4net; @@ -8,6 +9,7 @@ /// <summary> /// An error handler that counts parsing errors and warnings. /// </summary> + [CLSCompliant(false)] public class ErrorCounter : IParseErrorHandler { private static readonly ILog log = LogManager.GetLogger(typeof(ErrorCounter)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,3 +1,4 @@ +using System; using NHibernate.Engine; using NHibernate.SqlCommand; using log4net; @@ -4,6 +5,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Exec { + [CLSCompliant(false)] public abstract class AbstractStatementExecutor : IStatementExecutor { private readonly ILog log; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Exec { + [CLSCompliant(false)] public class BasicExecutor : AbstractStatementExecutor { private readonly IQueryable persister; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,22 +1,21 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { - public partial class HqlLexer - { - public override IToken Emit() - { - HqlToken t = new HqlToken(input, - state.type, - state.channel, - state.tokenStartCharIndex, - CharIndex - 1); + [CLSCompliant(false)] + public partial class HqlLexer + { + public override IToken Emit() + { + var t = new HqlToken(input, + state.type, + state.channel, + state.tokenStartCharIndex, + CharIndex - 1) {Line = state.tokenStartLine, Text = state.text}; - t.Line = state.tokenStartLine; - t.Text = state.text; - - Emit(t); - return t; - } - } + Emit(t); + return t; + } + } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public partial class HqlParser { private static readonly ILog log = LogManager.GetLogger(typeof(HqlParser)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -14,6 +14,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public partial class HqlSqlWalker { private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlWalker)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,11 +1,13 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { /// <summary> /// A custom token class for the HQL grammar. /// </summary> - public class HqlToken : CommonToken + [CLSCompliant(false)] + public class HqlToken : CommonToken { /// <summary> /// The previous token type. Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { @@ -7,6 +8,7 @@ /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public interface IErrorReporter { void ReportError(RecognitionException e); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,10 +1,13 @@ -namespace NHibernate.Hql.Ast.ANTLR +using System; + +namespace NHibernate.Hql.Ast.ANTLR { /// <summary> /// Defines the behavior of an error handler for the HQL parsers. /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public interface IParseErrorHandler : IErrorReporter { int GetErrorCount(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -19,6 +19,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Loader { + [CLSCompliant(false)] public class QueryLoader : BasicLoader { private readonly QueryTranslatorImpl _queryTranslator; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class QuerySyntaxException : QueryException { public QuerySyntaxException(string message) : base(message) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -18,6 +18,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class QueryTranslatorImpl : IFilterTranslator { private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); @@ -464,6 +465,7 @@ } } + [CLSCompliant(false)] public class HqlParseEngine { private static readonly ILog log = LogManager.GetLogger(typeof(HqlParseEngine)); @@ -579,6 +581,7 @@ } } + [CLSCompliant(false)] public class HqlSqlTranslator { private readonly IASTNode _inputAst; @@ -636,6 +639,7 @@ } } + [CLSCompliant(false)] public class HqlSqlGenerator { private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlGenerator)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -14,6 +14,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class SessionFactoryHelperExtensions { private readonly ISessionFactoryImplementor _sfi; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -17,6 +17,7 @@ /// Author: Joshua Davis, Steve Ebersole /// Ported By: Steve Strong /// </summary> + [CLSCompliant(false)] public partial class SqlGenerator : IErrorReporter { /// <summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime.Tree; +using System; +using Antlr.Runtime.Tree; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTFactory : IASTFactory { private readonly ITreeAdaptor _adaptor; @@ -11,13 +13,17 @@ _adaptor = adaptor; } + #region IASTFactory Members + public IASTNode CreateNode(int type, string text, params IASTNode[] children) { - IASTNode parent = (IASTNode)_adaptor.Create(type, text); + var parent = (IASTNode) _adaptor.Create(type, text); parent.AddChildren(children); return parent; } + + #endregion } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTNode : IASTNode, ITree { private int _startIndex; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,8 +1,10 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using Antlr.Runtime.Tree; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTTreeAdaptor : BaseTreeAdaptor { public override object DupNode(object t) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -13,6 +13,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public abstract class AbstractNullnessCheckNode : UnaryLogicOperatorNode { protected AbstractNullnessCheckNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,9 +1,11 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using log4net; using NHibernate.Hql.Ast.ANTLR.Util; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public abstract class AbstractRestrictableStatement : AbstractStatement, IRestrictableStatement { private FromClause _fromClause; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public abstract class AbstractSelectExpression : HqlSqlWalkerNode, ISelectExpression { private string _alias; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -9,6 +9,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public abstract class AbstractStatement : HqlSqlWalkerNode, IDisplayableNode, IStatement { protected AbstractStatement(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Type; using NHibernate.Hql.Ast.ANTLR.Util; @@ -10,6 +11,7 @@ /// Author: Joshua Davis /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class AggregateNode : AbstractSelectExpression, ISelectExpression { public AggregateNode(IToken token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,13 +1,13 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Contract for nodes representing logcial BETWEEN (ternary) operators. - * - * @author Steve Ebersole - */ + /// <summary> + /// Contract for nodes representing logcial BETWEEN (ternary) operators. + /// </summary> + [CLSCompliant(false)] public class BetweenOperatorNode : SqlNode, IOperatorNode { public BetweenOperatorNode(IToken token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -5,11 +5,10 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Nodes which represent binary arithmetic operators. - * - * @author Gavin King - */ + /// <summary> + /// Nodes which represent binary arithmetic operators. + /// </summary> + [CLSCompliant(false)] public class BinaryArithmeticOperatorNode : AbstractSelectExpression, IBinaryOperatorNode, IDisplayableNode { public BinaryArithmeticOperatorNode(IToken token) @@ -81,13 +80,13 @@ public override IType DataType { - /** - * Figure out the type of the binary expression by looking at - * the types of the operands. Sometimes we don't know both types, - * if, for example, one is a parameter. - */ get { + /* + * Figure out the type of the binary expression by looking at + * the types of the operands. Sometimes we don't know both types, + * if, for example, one is a parameter. + */ if (base.DataType == null) { base.DataType = ResolveDataType(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class BinaryLogicOperatorNode : HqlSqlWalkerNode, IBinaryOperatorNode { public BinaryLogicOperatorNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -5,11 +5,10 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Represents a boolean literal within a query. - * - * @author Steve Ebersole - */ + ///<summary> + /// Represents a boolean literal within a query. + ///</summary> + [CLSCompliant(false)] public class BooleanLiteralNode : LiteralNode, IExpectedTypeAwareNode { private IType expectedType; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,14 +1,14 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Represents a case ... when .. then ... else ... end expression in a select. - * - * @author Gavin King - */ + /// <summary> + /// Represents a case ... when .. then ... else ... end expression in a select. + /// </summary> + [CLSCompliant(false)] public class Case2Node : AbstractSelectExpression, ISelectExpression { public Case2Node(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Type; @@ -10,6 +11,7 @@ /// Author: Gavin King /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class CaseNode : AbstractSelectExpression, ISelectExpression { public CaseNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -8,6 +8,7 @@ /// Author: josh /// Ported by: Steve strong /// </summary> + [CLSCompliant(false)] public class CollectionFunction : MethodNode, IDisplayableNode { public CollectionFunction(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ConstructorNode : SelectExpressionList, ISelectExpression { private IType[] _constructorArgumentTypes; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -8,6 +8,7 @@ /// Defines a top-level AST node representing an HQL delete statement. /// </summary> [Serializable] + [CLSCompliant(false)] public class DeleteStatement : AbstractRestrictableStatement { private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -17,6 +17,7 @@ /// Author: Joshua Davis /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class DotNode : FromReferenceNode, ISelectExpression { private static readonly ILog log = LogManager.GetLogger(typeof(DotNode)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class FromClause : HqlSqlWalkerNode, IDisplayableNode { private static readonly ILog log = LogManager.GetLogger(typeof(FromClause)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class FromElement : HqlSqlWalkerNode, IDisplayableNode, IParameterContainer { private static readonly ILog log = LogManager.GetLogger(typeof(FromElement)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -10,568 +10,569 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - public class FromElementFactory - { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); + [CLSCompliant(false)] + public class FromElementFactory + { + private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); - private readonly FromClause _fromClause; - private readonly FromElement _origin; - private readonly string _path; - private readonly bool _collection; - private readonly string _classAlias; - private readonly string[] _columns; - private bool _implied; - private bool _inElementsFunction; - private IQueryableCollection _queryableCollection; - private CollectionType _collectionType; + private readonly FromClause _fromClause; + private readonly FromElement _origin; + private readonly string _path; + private readonly bool _collection; + private readonly string _classAlias; + private readonly string[] _columns; + private bool _implied; + private bool _inElementsFunction; + private IQueryableCollection _queryableCollection; + private CollectionType _collectionType; - /// <summary> - /// Creates entity from elements. - /// </summary> - /// <param name="fromClause"></param> - /// <param name="origin"></param> - /// <param name="path"></param> - public FromElementFactory(FromClause fromClause, FromElement origin, string path) - { - _fromClause = fromClause; - _origin = origin; - _path = path; - _collection = false; - } + /// <summary> + /// Creates entity from elements. + /// </summary> + /// <param name="fromClause"></param> + /// <param name="origin"></param> + /// <param name="path"></param> + public FromElementFactory(FromClause fromClause, FromElement origin, string path) + { + _fromClause = fromClause; + _origin = origin; + _path = path; + _collection = false; + } - /// <summary> - /// Creates collection from elements. - /// </summary> - /// <param name="fromClause"></param> - /// <param name="origin"></param> - /// <param name="path"></param> - /// <param name="classAlias"></param> - /// <param name="columns"></param> - /// <param name="implied"></param> - public FromElementFactory( - FromClause fromClause, - FromElement origin, - string path, - string classAlias, - string[] columns, - bool implied) - : this(fromClause, origin, path) - { - _classAlias = classAlias; - _columns = columns; - _implied = implied; - _collection = true; - } + /// <summary> + /// Creates collection from elements. + /// </summary> + /// <param name="fromClause"></param> + /// <param name="origin"></param> + /// <param name="path"></param> + /// <param name="classAlias"></param> + /// <param name="columns"></param> + /// <param name="implied"></param> + public FromElementFactory( + FromClause fromClause, + FromElement origin, + string path, + string classAlias, + string[] columns, + bool implied) + : this(fromClause, origin, path) + { + _classAlias = classAlias; + _columns = columns; + _implied = implied; + _collection = true; + } - public FromElement AddFromElement() - { - FromClause parentFromClause = _fromClause.ParentFromClause; - if (parentFromClause != null) - { - // Look up class name using the first identifier in the path. - string pathAlias = PathHelper.GetAlias(_path); - FromElement parentFromElement = parentFromClause.GetFromElement(pathAlias); - if (parentFromElement != null) - { - return CreateFromElementInSubselect(_path, pathAlias, parentFromElement, _classAlias); - } - } + public FromElement AddFromElement() + { + FromClause parentFromClause = _fromClause.ParentFromClause; + if (parentFromClause != null) + { + // Look up class name using the first identifier in the path. + string pathAlias = PathHelper.GetAlias(_path); + FromElement parentFromElement = parentFromClause.GetFromElement(pathAlias); + if (parentFromElement != null) + { + return CreateFromElementInSubselect(_path, pathAlias, parentFromElement, _classAlias); + } + } - IEntityPersister entityPersister = _fromClause.SessionFactoryHelper.RequireClassPersister(_path); + IEntityPersister entityPersister = _fromClause.SessionFactoryHelper.RequireClassPersister(_path); - FromElement elem = CreateAndAddFromElement(_path, - _classAlias, - entityPersister, - (EntityType)((IQueryable)entityPersister).Type, - null); + FromElement elem = CreateAndAddFromElement(_path, + _classAlias, + entityPersister, + (EntityType)((IQueryable)entityPersister).Type, + null); - // Add to the query spaces. - _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); + // Add to the query spaces. + _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); - return elem; - } + return elem; + } - public FromElement CreateCollectionElementsJoin(IQueryableCollection queryableCollection, - String collectionName) - { - JoinSequence collectionJoinSequence = _fromClause.SessionFactoryHelper.CreateCollectionJoinSequence(queryableCollection, collectionName); - _queryableCollection = queryableCollection; - return CreateCollectionJoin(collectionJoinSequence, null); - } + public FromElement CreateCollectionElementsJoin(IQueryableCollection queryableCollection, + String collectionName) + { + JoinSequence collectionJoinSequence = _fromClause.SessionFactoryHelper.CreateCollectionJoinSequence(queryableCollection, collectionName); + _queryableCollection = queryableCollection; + return CreateCollectionJoin(collectionJoinSequence, null); + } - private FromElement CreateFromElementInSubselect( - string path, - string pathAlias, - FromElement parentFromElement, - string classAlias) - { - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : path = " + path); - } + private FromElement CreateFromElementInSubselect( + string path, + string pathAlias, + FromElement parentFromElement, + string classAlias) + { + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : path = " + path); + } - // Create an DotNode AST for the path and resolve it. - FromElement fromElement = EvaluateFromElementPath(path, classAlias); - IEntityPersister entityPersister = fromElement.EntityPersister; + // Create an DotNode AST for the path and resolve it. + FromElement fromElement = EvaluateFromElementPath(path, classAlias); + IEntityPersister entityPersister = fromElement.EntityPersister; - // If the first identifier in the path referrs to the class alias (not the class name), then this - // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. Otherwise - // generate a new one. - string tableAlias; - bool correlatedSubselect = pathAlias == parentFromElement.ClassAlias; - if (correlatedSubselect) - { - tableAlias = fromElement.TableAlias; - } - else - { - tableAlias = null; - } + // If the first identifier in the path referrs to the class alias (not the class name), then this + // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. Otherwise + // generate a new one. + string tableAlias; + bool correlatedSubselect = pathAlias == parentFromElement.ClassAlias; + if (correlatedSubselect) + { + tableAlias = fromElement.TableAlias; + } + else + { + tableAlias = null; + } - // If the from element isn't in the same clause, create a new from element. - if (fromElement.FromClause != _fromClause) - { - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : creating a new FROM element..."); - } + // If the from element isn't in the same clause, create a new from element. + if (fromElement.FromClause != _fromClause) + { + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : creating a new FROM element..."); + } - fromElement = CreateFromElement(entityPersister); + fromElement = CreateFromElement(entityPersister); - InitializeAndAddFromElement(fromElement, - path, - classAlias, - entityPersister, - (EntityType)((IQueryable)entityPersister).Type, - tableAlias - ); - } - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); - } + InitializeAndAddFromElement(fromElement, + path, + classAlias, + entityPersister, + (EntityType)((IQueryable)entityPersister).Type, + tableAlias + ); + } + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); + } - return fromElement; - } + return fromElement; + } - public FromElement CreateCollection(IQueryableCollection queryableCollection, - string role, - JoinType joinType, - bool fetchFlag, - bool indexed) - { - if (!_collection) - { - throw new InvalidOperationException("FromElementFactory not initialized for collections!"); - } + public FromElement CreateCollection(IQueryableCollection queryableCollection, + string role, + JoinType joinType, + bool fetchFlag, + bool indexed) + { + if (!_collection) + { + throw new InvalidOperationException("FromElementFactory not initialized for collections!"); + } - _inElementsFunction = indexed; - FromElement elem; - _queryableCollection = queryableCollection; - _collectionType = queryableCollection.CollectionType; - string roleAlias = _fromClause.AliasGenerator.CreateName(role); + _inElementsFunction = indexed; + FromElement elem; + _queryableCollection = queryableCollection; + _collectionType = queryableCollection.CollectionType; + string roleAlias = _fromClause.AliasGenerator.CreateName(role); - // Correlated subqueries create 'special' implied from nodes - // because correlated subselects can't use an ANSI-style join - bool explicitSubqueryFromElement = _fromClause.IsSubQuery && !_implied; - if (explicitSubqueryFromElement) - { - string pathRoot = StringHelper.Root(_path); - FromElement origin = _fromClause.GetFromElement(pathRoot); - if (origin == null || origin.FromClause != _fromClause) - { - _implied = true; - } - } + // Correlated subqueries create 'special' implied from nodes + // because correlated subselects can't use an ANSI-style join + bool explicitSubqueryFromElement = _fromClause.IsSubQuery && !_implied; + if (explicitSubqueryFromElement) + { + string pathRoot = StringHelper.Root(_path); + FromElement origin = _fromClause.GetFromElement(pathRoot); + if (origin == null || origin.FromClause != _fromClause) + { + _implied = true; + } + } - // super-duper-classic-parser-regression-testing-mojo-magic... - if (explicitSubqueryFromElement && DotNode.UseThetaStyleImplicitJoins) - { - _implied = true; - } + // super-duper-classic-parser-regression-testing-mojo-magic... + if (explicitSubqueryFromElement && DotNode.UseThetaStyleImplicitJoins) + { + _implied = true; + } - IType elementType = queryableCollection.ElementType; + IType elementType = queryableCollection.ElementType; - if (elementType.IsEntityType) - { - // A collection of entities... - elem = CreateEntityAssociation(role, roleAlias, joinType); - } - else if (elementType.IsComponentType) - { - // A collection of components... - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateCollectionJoin(joinSequence, roleAlias); - } - else - { - // A collection of scalar elements... - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateCollectionJoin(joinSequence, roleAlias); - } + if (elementType.IsEntityType) + { + // A collection of entities... + elem = CreateEntityAssociation(role, roleAlias, joinType); + } + else if (elementType.IsComponentType) + { + // A collection of components... + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + elem = CreateCollectionJoin(joinSequence, roleAlias); + } + else + { + // A collection of scalar elements... + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + elem = CreateCollectionJoin(joinSequence, roleAlias); + } - elem.SetRole(role); - elem.QueryableCollection = queryableCollection; - // Don't include sub-classes for implied collection joins or subquery joins. - if (_implied) - { - elem.IncludeSubclasses = false; - } + elem.SetRole(role); + elem.QueryableCollection = queryableCollection; + // Don't include sub-classes for implied collection joins or subquery joins. + if (_implied) + { + elem.IncludeSubclasses = false; + } - if (explicitSubqueryFromElement) - { - elem.InProjectionList = true; // Treat explict from elements in sub-queries properly. - } + if (explicitSubqueryFromElement) + { + elem.InProjectionList = true; // Treat explict from elements in sub-queries properly. + } - if (fetchFlag) - { - elem.Fetch = true; - } - return elem; - } + if (fetchFlag) + { + elem.Fetch = true; + } + return elem; + } - public FromElement CreateElementJoin(IQueryableCollection queryableCollection) - { - FromElement elem; + public FromElement CreateElementJoin(IQueryableCollection queryableCollection) + { + FromElement elem; - _implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause - _inElementsFunction = true; + _implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause + _inElementsFunction = true; - IType elementType = queryableCollection.ElementType; + IType elementType = queryableCollection.ElementType; - if (!elementType.IsEntityType) - { - throw new InvalidOperationException("Cannot create element join for a collection of non-entities!"); - } + if (!elementType.IsEntityType) + { + throw new InvalidOperationException("Cannot create element join for a collection of non-entities!"); + } - _queryableCollection = queryableCollection; + _queryableCollection = queryableCollection; - SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; - FromElement destination = null; - string tableAlias = null; - IEntityPersister entityPersister = queryableCollection.ElementPersister; - tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); - string associatedEntityName = entityPersister.EntityName; - IEntityPersister targetEntityPersister = sfh.RequireClassPersister(associatedEntityName); + SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; + FromElement destination = null; + string tableAlias = null; + IEntityPersister entityPersister = queryableCollection.ElementPersister; + tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); + string associatedEntityName = entityPersister.EntityName; + IEntityPersister targetEntityPersister = sfh.RequireClassPersister(associatedEntityName); - // Create the FROM element for the target (the elements of the collection). - destination = CreateAndAddFromElement( - associatedEntityName, - _classAlias, - targetEntityPersister, - (EntityType)queryableCollection.ElementType, - tableAlias - ); + // Create the FROM element for the target (the elements of the collection). + destination = CreateAndAddFromElement( + associatedEntityName, + _classAlias, + targetEntityPersister, + (EntityType)queryableCollection.ElementType, + tableAlias + ); - // If the join is implied, then don't include sub-classes on the element. - if (_implied) - { - destination.IncludeSubclasses = false; - } + // If the join is implied, then don't include sub-classes on the element. + if (_implied) + { + destination.IncludeSubclasses = false; + } - _fromClause.AddCollectionJoinFromElementByPath(_path, destination); - // origin.addDestination(destination); - // Add the query spaces. - _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); + _fromClause.AddCollectionJoinFromElementByPath(_path, destination); + // origin.addDestination(destination); + // Add the query spaces. + _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); - CollectionType type = queryableCollection.CollectionType; - string role = type.Role; - string roleAlias = _origin.TableAlias; + CollectionType type = queryableCollection.CollectionType; + string role = type.Role; + string roleAlias = _origin.TableAlias; - string[] targetColumns = sfh.GetCollectionElementColumns(role, roleAlias); - IAssociationType elementAssociationType = sfh.GetElementAssociationType(type); + string[] targetColumns = sfh.GetCollectionElementColumns(role, roleAlias); + IAssociationType elementAssociationType = sfh.GetElementAssociationType(type); - // Create the join element under the from element. - JoinType joinType = JoinType.InnerJoin; - JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, joinType, targetColumns); - elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); - elem.UseFromFragment = true; // The associated entity is implied, but it must be included in the FROM. - elem.CollectionTableAlias = roleAlias; // The collection alias is the role. - return elem; - } + // Create the join element under the from element. + JoinType joinType = JoinType.InnerJoin; + JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, joinType, targetColumns); + elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); + elem.UseFromFragment = true; // The associated entity is implied, but it must be included in the FROM. + elem.CollectionTableAlias = roleAlias; // The collection alias is the role. + return elem; + } - public FromElement CreateEntityJoin( - string entityClass, - string tableAlias, - JoinSequence joinSequence, - bool fetchFlag, - bool inFrom, - EntityType type) - { - FromElement elem = CreateJoin(entityClass, tableAlias, joinSequence, type, false); - elem.Fetch = fetchFlag; - IEntityPersister entityPersister = elem.EntityPersister; - int numberOfTables = entityPersister.QuerySpaces.Length; + public FromElement CreateEntityJoin( + string entityClass, + string tableAlias, + JoinSequence joinSequence, + bool fetchFlag, + bool inFrom, + EntityType type) + { + FromElement elem = CreateJoin(entityClass, tableAlias, joinSequence, type, false); + elem.Fetch = fetchFlag; + IEntityPersister entityPersister = elem.EntityPersister; + int numberOfTables = entityPersister.QuerySpaces.Length; - if (numberOfTables > 1 && _implied && !elem.UseFromFragment) - { - if (log.IsDebugEnabled) - { - log.Debug("createEntityJoin() : Implied multi-table entity join"); - } - elem.UseFromFragment = true; - } + if (numberOfTables > 1 && _implied && !elem.UseFromFragment) + { + if (log.IsDebugEnabled) + { + log.Debug("createEntityJoin() : Implied multi-table entity join"); + } + elem.UseFromFragment = true; + } - // If this is an implied join in a FROM clause, then use ANSI-style joining, and set the - // flag on the FromElement that indicates that it was implied in the FROM clause itself. - if (_implied && inFrom) - { - joinSequence.SetUseThetaStyle(false); - elem.UseFromFragment = true; - elem.SetImpliedInFromClause(true); - } - if (elem.Walker.IsSubQuery) - { - // two conditions where we need to transform this to a theta-join syntax: - // 1) 'elem' is the "root from-element" in correlated subqueries - // 2) The DotNode.useThetaStyleImplicitJoins has been set to true - // and 'elem' represents an implicit join - if (elem.FromClause != elem.Origin.FromClause || - // ( implied && DotNode.useThetaStyleImplicitJoins ) ) { - DotNode.UseThetaStyleImplicitJoins) - { - // the "root from-element" in correlated subqueries do need this piece - elem.Type = HqlSqlWalker.FROM_FRAGMENT; - joinSequence.SetUseThetaStyle(true); - elem.UseFromFragment = false; - } - } + // If this is an implied join in a FROM clause, then use ANSI-style joining, and set the + // flag on the FromElement that indicates that it was implied in the FROM clause itself. + if (_implied && inFrom) + { + joinSequence.SetUseThetaStyle(false); + elem.UseFromFragment = true; + elem.SetImpliedInFromClause(true); + } + if (elem.Walker.IsSubQuery) + { + // two conditions where we need to transform this to a theta-join syntax: + // 1) 'elem' is the "root from-element" in correlated subqueries + // 2) The DotNode.useThetaStyleImplicitJoins has been set to true + // and 'elem' represents an implicit join + if (elem.FromClause != elem.Origin.FromClause || + // ( implied && DotNode.useThetaStyleImplicitJoins ) ) { + DotNode.UseThetaStyleImplicitJoins) + { + // the "root from-element" in correlated subqueries do need this piece + elem.Type = HqlSqlWalker.FROM_FRAGMENT; + joinSequence.SetUseThetaStyle(true); + elem.UseFromFragment = false; + } + } - return elem; - } + return elem; + } - private FromElement CreateEntityAssociation( - string role, - string roleAlias, - JoinType joinType) - { - FromElement elem; - IQueryable entityPersister = (IQueryable)_queryableCollection.ElementPersister; - string associatedEntityName = entityPersister.EntityName; + private FromElement CreateEntityAssociation( + string role, + string roleAlias, + JoinType joinType) + { + FromElement elem; + IQueryable entityPersister = (IQueryable)_queryableCollection.ElementPersister; + string associatedEntityName = entityPersister.EntityName; - // Get the class name of the associated entity. - if (_queryableCollection.IsOneToMany) - { - if (log.IsDebugEnabled) - { - log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); - } + // Get the class name of the associated entity. + if (_queryableCollection.IsOneToMany) + { + if (log.IsDebugEnabled) + { + log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + } - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateJoin(associatedEntityName, roleAlias, joinSequence, (EntityType)_queryableCollection.ElementType, false); - } - else - { - if (log.IsDebugEnabled) - { - log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); - } + elem = CreateJoin(associatedEntityName, roleAlias, joinSequence, (EntityType)_queryableCollection.ElementType, false); + } + else + { + if (log.IsDebugEnabled) + { + log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + } - elem = CreateManyToMany(role, associatedEntityName, - roleAlias, entityPersister, (EntityType)_queryableCollection.ElementType, joinType); - _fromClause.Walker.AddQuerySpaces(_queryableCollection.CollectionSpaces); - } - elem.CollectionTableAlias = roleAlias; - return elem; - } + elem = CreateManyToMany(role, associatedEntityName, + roleAlias, entityPersister, (EntityType)_queryableCollection.ElementType, joinType); + _fromClause.Walker.AddQuerySpaces(_queryableCollection.CollectionSpaces); + } + elem.CollectionTableAlias = roleAlias; + return elem; + } - private FromElement CreateCollectionJoin(JoinSequence collectionJoinSequence, string tableAlias) - { - string text = _queryableCollection.TableName; - IASTNode ast = CreateFromElement(text); - FromElement destination = (FromElement)ast; - IType elementType = _queryableCollection.ElementType; + private FromElement CreateCollectionJoin(JoinSequence collectionJoinSequence, string tableAlias) + { + string text = _queryableCollection.TableName; + IASTNode ast = CreateFromElement(text); + FromElement destination = (FromElement)ast; + IType elementType = _queryableCollection.ElementType; - if (elementType.IsCollectionType) - { - throw new SemanticException("Collections of collections are not supported!"); - } + if (elementType.IsCollectionType) + { + throw new SemanticException("Collections of collections are not supported!"); + } - destination.InitializeCollection(_fromClause, _classAlia... [truncated message content] |
From: <fab...@us...> - 2009-04-30 18:44:57
|
Revision: 4218 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4218&view=rev Author: fabiomaulo Date: 2009-04-30 18:44:49 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Starting executable HQL (Delete) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,37 @@ +using System; +using Antlr.Runtime; +using log4net; + +namespace NHibernate.Hql.Ast.ANTLR.Tree +{ + /// <summary> + /// Defines a top-level AST node representing an HQL delete statement. + /// </summary> + [Serializable] + public class DeleteStatement : AbstractRestrictableStatement + { + private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); + + public DeleteStatement(IToken token) : base(token) {} + + public override bool NeedsExecutor + { + get { return true; } + } + + public override int StatementType + { + get { return HqlSqlWalker.DELETE; } + } + + protected override ILog GetLog() + { + return log; + } + + protected override int GetWhereClauseParentTokenType() + { + return HqlSqlWalker.FROM; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 17:54:10 UTC (rev 4217) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 18:44:49 UTC (rev 4218) @@ -528,6 +528,7 @@ <Compile Include="Hql\Ast\ANTLR\Tree\CollectionFunction.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\ConstructorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\CountNode.cs" /> + <Compile Include="Hql\Ast\ANTLR\Tree\DeleteStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\DotNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\FromClause.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\FromElement.cs" /> Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,47 @@ +using System.Collections; +using NHibernate.Hql.Ast.ANTLR; +using System.Collections.Generic; +using NHibernate.Util; +using NHibernate.Hql.Classic; + +namespace NHibernate.Test.BulkManipulation +{ + public class BaseFixture: TestCase + { + private readonly IDictionary<string, IFilter> emptyfilters = new CollectionHelper.EmptyMapClass<string, IFilter>(); + + protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) + { + return !(factory.Settings.QueryTranslatorFactory is ClassicQueryTranslatorFactory); + } + + #region Overrides of TestCase + + protected override IList Mappings + { + get { return new string[0]; } + } + + #endregion + + protected override void Configure(Cfg.Configuration configuration) + { + var assembly = GetType().Assembly; + string mappingNamespace = GetType().Namespace; + foreach (var resource in assembly.GetManifestResourceNames()) + { + if (resource.StartsWith(mappingNamespace) && resource.EndsWith(".hbm.xml")) + { + configuration.AddResource(resource, assembly); + } + } + } + + public string GetSql(string query) + { + var qt = new QueryTranslatorImpl(null, query, emptyfilters, sessions); + qt.Compile(null, false); + return qt.SQLString; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,34 @@ +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.BulkManipulation +{ + [TestFixture] + public class HqlBulkOperations: BaseFixture + { + [Test, Ignore("Not supported yet.")] + public void SimpleDelete() + { + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Save(new SimpleClass {Description = "simple1"}); + s.Save(new SimpleClass {Description = "simple2"}); + tx.Commit(); + } + + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.CreateQuery("delete from SimpleClass").ExecuteUpdate(); + tx.Commit(); + } + + using (var s = OpenSession()) + { + var l = s.CreateQuery("from SimpleClass").List(); + Assert.That(l.Count, Is.EqualTo(0)); + } + } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.BulkManipulation +{ + public class SimpleClass + { + public virtual string Description { get; set; } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.BulkManipulation"> + + <class name="SimpleClass"> + <id type="int"> + <generator class="native" /> + </id> + <property name="Description"/> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-30 17:54:10 UTC (rev 4217) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-30 18:44:49 UTC (rev 4218) @@ -81,6 +81,9 @@ <Compile Include="AssemblyInfo.cs" /> <Compile Include="Assertions\InheritedAreMarkedSerializable.cs" /> <Compile Include="Assertions\IsSerializable.cs" /> + <Compile Include="BulkManipulation\BaseFixture.cs" /> + <Compile Include="BulkManipulation\HQLBulkOperations.cs" /> + <Compile Include="BulkManipulation\SimpleClass.cs" /> <Compile Include="Bytecode\Lightweight\BytecodeProviderFixture.cs" /> <Compile Include="Bytecode\WrongProxyFactoryFactory.cs" /> <Compile Include="CacheTest\CacheFixture.cs" /> @@ -1722,6 +1725,7 @@ <EmbeddedResource Include="Cascade\Job.hbm.xml" /> <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> + <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1727\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1742\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Tuna T. <te...@gm...> - 2009-04-30 17:56:41
|
What is executable hql? Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Apr 30, 2009 at 8:54 PM, <fab...@us...> wrote: > executable HQL > |
From: <fab...@us...> - 2009-04-30 17:54:12
|
Revision: 4217 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4217&view=rev Author: fabiomaulo Date: 2009-04-30 17:54:10 +0000 (Thu, 30 Apr 2009) Log Message: ----------- continue work on executable HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -0,0 +1,23 @@ +using NHibernate.Engine; +using NHibernate.SqlCommand; +using log4net; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public abstract class AbstractStatementExecutor : IStatementExecutor + { + private readonly ILog log; + + protected AbstractStatementExecutor(HqlSqlWalker walker, ILog log) + { + Walker = walker; + this.log = log; + } + + protected HqlSqlWalker Walker { get; private set; } + + public abstract SqlString[] SqlStatements{get;} + + public abstract int Execute(QueryParameters parameters, ISessionImplementor session); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using Antlr.Runtime; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public class BasicExecutor : AbstractStatementExecutor + { + private readonly IQueryable persister; + private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); + private SqlString sql; + + public BasicExecutor(HqlSqlWalker walker, IQueryable persister) : base(walker, log) + { + this.persister = persister; + try + { + + //SqlGenerator gen = new SqlGenerator(Factory); + //gen.statement(walker.getAST()); + //sql = gen.GetSQL(); + //gen.ParseErrorHandler.ThrowQueryException(); + } + catch (RecognitionException e) + { + throw QuerySyntaxException.Convert(e); + } + } + + protected ISessionFactoryImplementor Factory + { + get + { + return Walker.SessionFactoryHelper.Factory; + } + } + + public override SqlString[] SqlStatements + { + get { return new[] {sql}; } + } + + public override int Execute(QueryParameters parameters, ISessionImplementor session) + { + //CoordinateSharedCacheCleanup(session); + + IDbCommand st = null; + RowSelection selection = parameters.RowSelection; + + try + { + try + { + //st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes); + IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + int pos = 1; + while (paramSpecifications.MoveNext()) + { + var paramSpec = paramSpecifications.Current; + pos += paramSpec.Bind(st, parameters, session, pos); + } + if (selection != null) + { + if (selection.Timeout != RowSelection.NoValue) + { + st.CommandTimeout = selection.Timeout; + } + } + return session.Batcher.ExecuteNonQuery(st); + } + finally + { + if (st != null) + { + session.Batcher.CloseCommand(st, null); + } + } + } + catch (DbException sqle) + { + throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, + "could not execute update query", sql); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-29 22:09:01 UTC (rev 4216) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -6,10 +6,12 @@ using Iesi.Collections.Generic; using log4net; using NHibernate.Engine; +using NHibernate.Hql.Ast.ANTLR.Exec; using NHibernate.Hql.Ast.ANTLR.Loader; using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -27,8 +29,10 @@ private IDictionary<string, IFilter> _enabledFilters; private readonly ISessionFactoryImplementor _factory; private QueryLoader _queryLoader; - private ParameterTranslationsImpl _paramTranslations; - + private IStatementExecutor statementExecutor; + private IStatement sqlAst; + private ParameterTranslationsImpl _paramTranslations; + private IDictionary<string, string> tokenReplacements; private HqlParseEngine _parser; private HqlSqlTranslator _translator; private HqlSqlGenerator _generator; @@ -202,7 +206,7 @@ public IStatement SqlAST { - get { return _translator.SqlStatement; } + get { return sqlAst; } } public IList<IParameterSpecification> CollectedParameterSpecifications @@ -322,27 +326,21 @@ return; } - if (replacements == null) - { - replacements = new Dictionary<string, string>(); - } + // Remember the parameters for the compilation. + tokenReplacements = replacements ?? new Dictionary<string, string>(1); _shallowQuery = shallow; try { // PHASE 1 : Parse the HQL into an AST. - if (_parser == null) - { - _parser = new HqlParseEngine(_hql, true, _factory); - _parser.Parse(); - } + HqlParseEngine parser = Parse(true); // PHASE 2 : Analyze the HQL AST, and produce an SQL AST. - _translator = new HqlSqlTranslator(_parser.Ast, _parser.Tokens, this, _factory, replacements, - collectionRole); - _translator.Translate(); - + HqlSqlWalker w = Analyze(parser, collectionRole); + + sqlAst = (IStatement)w.statement().Tree; + // at some point the generate phase needs to be moved out of here, // because a single object-level DML might spawn multiple SQL DML // command executions. @@ -356,16 +354,15 @@ if (_translator.SqlStatement.NeedsExecutor) { - throw new NotImplementedException(); // DML -// statementExecutor = buildAppropriateStatementExecutor( w ); + statementExecutor = BuildAppropriateStatementExecutor(w); } else { // PHASE 3 : Generate the SQL. - _generator = new HqlSqlGenerator(_translator.SqlStatement, _parser.Tokens, _factory); + _generator = new HqlSqlGenerator(_translator.SqlStatement, parser.Tokens, _factory); _generator.Generate(); - - _queryLoader = new QueryLoader( this, _factory, _translator.SqlStatement.Walker.SelectClause ); + + _queryLoader = new QueryLoader(this, _factory, w.SelectClause); } _compiled = true; @@ -389,6 +386,70 @@ _enabledFilters = null; //only needed during compilation phase... } + private IStatementExecutor BuildAppropriateStatementExecutor(HqlSqlWalker walker) + { + if (walker.StatementType == HqlSqlWalker.DELETE) + { + FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); + IQueryable persister = fromElement.Queryable; + if (persister.IsMultiTable) + { + throw new NotSupportedException(); + //return new MultiTableDeleteExecutor(walker); + } + else + { + return new BasicExecutor(walker, persister); + } + } + else if (walker.StatementType == HqlSqlWalker.UPDATE) + { + FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); + IQueryable persister = fromElement.Queryable; + if (persister.IsMultiTable) + { + // even here, if only properties mapped to the "base table" are referenced + // in the set and where clauses, this could be handled by the BasicDelegate. + // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate + throw new NotSupportedException(); + //return new MultiTableUpdateExecutor(walker); + } + else + { + return new BasicExecutor(walker, persister); + } + } + else if (walker.StatementType == HqlSqlWalker.INSERT) + { + //var statement = (IStatement)walker.statement().Tree; + + throw new QueryException("Unexpected statement type"); + } + else + { + throw new QueryException("Unexpected statement type"); + } + } + + private HqlSqlWalker Analyze(HqlParseEngine parser, string collectionRole) + { + _translator = new HqlSqlTranslator(parser.Ast, parser.Tokens, this, _factory, tokenReplacements, + collectionRole); + _translator.Translate(); + + return _translator.SqlStatement.Walker; + } + + private HqlParseEngine Parse(bool isFilter) + { + if (_parser == null) + { + _parser = new HqlParseEngine(_hql, isFilter, _factory); + _parser.Parse(); + } + return _parser; + } + private void ErrorIfDML() { if (_translator.SqlStatement.NeedsExecutor) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 22:09:01 UTC (rev 4216) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 17:54:10 UTC (rev 4217) @@ -480,6 +480,8 @@ <Compile Include="Hql\Ast\ANTLR\CollectionProperties.cs" /> <Compile Include="Hql\Ast\ANTLR\DetailedSemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\ErrorCounter.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\AbstractStatementExecutor.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\BasicExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-29 22:09:11
|
Revision: 4216 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4216&view=rev Author: fabiomaulo Date: 2009-04-29 22:09:01 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Starting executable HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs 2009-04-29 22:09:01 UTC (rev 4216) @@ -0,0 +1,23 @@ +using NHibernate.Engine; +using NHibernate.SqlCommand; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + /// <summary> + /// Encapsulates the strategy required to execute various types of update, delete, + /// and insert statements issued through HQL. + /// </summary> + public interface IStatementExecutor + { + SqlString[] SqlStatements { get; } + + /// <summary> + /// Execute the sql managed by this executor using the given parameters. + /// </summary> + /// <param name="parameters">Essentially bind information for this processing. </param> + /// <param name="session">The session originating the request. </param> + /// <returns> The number of entities updated/deleted. </returns> + /// <exception cref="HibernateException"/> + int Execute(QueryParameters parameters, ISessionImplementor session); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 21:10:10 UTC (rev 4215) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 22:09:01 UTC (rev 4216) @@ -480,6 +480,7 @@ <Compile Include="Hql\Ast\ANTLR\CollectionProperties.cs" /> <Compile Include="Hql\Ast\ANTLR\DetailedSemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\ErrorCounter.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-29 21:10:11
|
Revision: 4215 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4215&view=rev Author: fabiomaulo Date: 2009-04-29 21:10:10 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Test isolation for ANTLR parser Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Legacy/ABCProxyTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/ABCProxyTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/ABCProxyTest.cs 2009-04-27 18:43:11 UTC (rev 4214) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/ABCProxyTest.cs 2009-04-29 21:10:10 UTC (rev 4215) @@ -264,6 +264,43 @@ } [Test] + public void OnoToOneComparing() + { + if (IsAntlrParser) + { + Assert.Ignore("ANTLR parser : Not supported "); + } + A a = new A(); + E d1 = new E(); + C1 c = new C1(); + E d2 = new E(); + a.Forward = d1; + d1.Reverse = a; + c.Forward = d2; + d2.Reverse = c; + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(a); + s.Save(d2); + t.Commit(); + } + using (ISession s = OpenSession()) + { + IList l = s.CreateQuery("from E e, A a where e.Reverse = a.Forward and a = ?").SetEntity(0, a).List(); + Assert.AreEqual(1, l.Count); + } + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from A"); + s.Delete("from E"); + t.Commit(); + } + } + + [Test] public void OneToOne() { A a = new A(); @@ -289,8 +326,7 @@ using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { - IList l = s.CreateQuery("from E e, A a where e.Reverse = a.Forward and a = ?").SetEntity(0, a).List(); - Assert.AreEqual(1, l.Count); + IList l; l = s.CreateQuery("from E e join fetch e.Reverse").List(); Assert.AreEqual(2, l.Count); t.Commit(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |