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: <ste...@us...> - 2009-05-13 09:17:48
|
Revision: 4288 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4288&view=rev Author: steverstrong Date: 2009-05-13 09:17:42 +0000 (Wed, 13 May 2009) Log Message: ----------- Removed some code smells form AST parser; specifically, improved the way it deals with SqlStrings internally, and removed a hack that was in place to support old HQL syntax. Modified Paths: -------------- 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/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.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/Tree/SqlNode.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -682,12 +682,13 @@ IASTNode CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch) { - try + // try { FromElement fromElement = _currentFromClause.AddFromElement(path, alias); fromElement.SetAllPropertyFetch(propertyFetch != null); return fromElement; } + /* catch (Exception e) { // Try resolving as if it were a join @@ -703,7 +704,7 @@ { throw e; } - } + }*/ } private IASTNode PreProcessPathForJoin(IASTNode node) @@ -1111,7 +1112,6 @@ sql.whereExpr(); fromElement.SetWithClauseFragment(visitor.GetJoinAlias(), "(" + sql.GetSQL() + ")"); - } catch (SemanticException) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -227,7 +227,7 @@ public SqlString SqlString { - get { return SqlString.Parse(_generator.Sql.ToString()); } + get { return _generator.Sql; } } public string QueryIdentifier Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -356,7 +356,8 @@ private class FunctionArguments : ISqlWriter { - private readonly List<object> args = new List<object>(); + //private readonly List<object> args = new List<object>(); + private readonly List<SqlString> args = new List<SqlString>(); private int argInd; public IList Args @@ -368,6 +369,8 @@ public void Clause(string clause) { + Clause(SqlString.Parse(clause)); + /* if (argInd == args.Count) { args.Add(clause); @@ -376,16 +379,25 @@ { args[argInd] = args[argInd] + clause; } + */ } public void Clause(SqlString clause) { - Clause(clause.ToString()); + //Clause(clause.ToString()); + if (argInd == args.Count) + { + args.Add(clause); + } + else + { + args[argInd] = args[argInd].Append(clause); + } } public void Parameter() { - args.Add(SqlCommand.Parameter.Placeholder); + args.Add(new SqlString(SqlCommand.Parameter.Placeholder)); } public void CommaBetweenParameters(string comma) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -1,6 +1,7 @@ using System; using Antlr.Runtime; using NHibernate.Engine; +using NHibernate.SqlCommand; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree @@ -49,11 +50,11 @@ set { expectedType = value; } } - public override string RenderText(ISessionFactoryImplementor sessionFactory) + public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) { try { - return GetTypeInternal().ObjectToSQLString( GetValue(), sessionFactory.Dialect ); + return new SqlString(GetTypeInternal().ObjectToSQLString( GetValue(), sessionFactory.Dialect )); } catch( Exception t ) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -7,6 +7,7 @@ using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -51,7 +52,7 @@ _isAllPropertyFetch = fetch; } - public void SetWithClauseFragment(String withClauseJoinAlias, String withClauseFragment) + public void SetWithClauseFragment(String withClauseJoinAlias, string withClauseFragment) { _withClauseJoinAlias = withClauseJoinAlias; _withClauseFragment = withClauseFragment; @@ -306,6 +307,11 @@ return _elementType.RenderPropertySelect(size, k, IsAllPropertyFetch); } + public override SqlString RenderText(NHibernate.Engine.ISessionFactoryImplementor sessionFactory) + { + return SqlString.Parse(Text); + } + public string RenderCollectionSelectFragment(int size, int k) { return _elementType.RenderCollectionSelectFragment(size, k); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -3,6 +3,7 @@ using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -38,12 +39,12 @@ set { _factory = value; } } - public override string RenderText(ISessionFactoryImplementor sessionFactory) + public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) { ProcessText(); IType type = _expectedType ?? _heuristicType; - return ResolveToLiteralString( type ); + return new SqlString(ResolveToLiteralString( type )); } private string ResolveToLiteralString(IType type) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -3,6 +3,7 @@ using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Param; +using NHibernate.SqlCommand; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree @@ -46,23 +47,25 @@ } } - public override string RenderText(ISessionFactoryImplementor sessionFactory) + public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) { int count = 0; if (ExpectedType != null && (count = ExpectedType.GetColumnSpan(sessionFactory)) > 1) { - StringBuilder buffer = new StringBuilder(); - buffer.Append("(?"); + SqlStringBuilder buffer = new SqlStringBuilder(); + buffer.Add("("); + buffer.AddParameter(); for (int i = 1; i < count; i++) { - buffer.Append(", ?"); + buffer.Add(","); + buffer.AddParameter(); } - buffer.Append(")"); - return buffer.ToString(); + buffer.Add(")"); + return buffer.ToSqlString(); } else { - return "?"; + return new SqlString(Parameter.Placeholder); } } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -37,6 +37,11 @@ set { _fromElement = value; } } + public override SqlString RenderText(NHibernate.Engine.ISessionFactoryImplementor sessionFactory) + { + return SqlString.Parse(Text); + } + // ParameterContainer impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private List<IParameterSpecification> _embeddedParameters; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -1,6 +1,7 @@ using System; using Antlr.Runtime; using NHibernate.Engine; +using NHibernate.SqlCommand; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree @@ -48,13 +49,13 @@ /// </summary> /// <param name="sessionFactory">The session factory</param> /// <returns>The text to use for rendering</returns> - public virtual String RenderText(ISessionFactoryImplementor sessionFactory) + public virtual SqlString RenderText(ISessionFactoryImplementor sessionFactory) { // The basic implementation is to simply use the node's text - return Text; + return new SqlString(Text); } - public String getOriginalText() + public string getOriginalText() { return _originalText; } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -73,7 +73,7 @@ ITransaction txn = s.BeginTransaction(); // one-to-many - IList list = + IList list = s.CreateQuery("from Human h inner join h.offspring as o with o.bodyWeight < :someLimit").SetDouble("someLimit", 1). List(); Assert.That(list, Is.Empty, "ad-hoc on did not take effect"); Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -2203,7 +2203,7 @@ s = OpenSession(); baz = (Baz) s.Load(typeof(Baz), baz.Code); Assert.AreEqual(1, baz.FooArray.Length); - Assert.AreEqual(1, s.CreateQuery("from Baz baz, baz.FooArray foo").List().Count); + Assert.AreEqual(1, s.CreateQuery("from Baz baz join baz.FooArray foo").List().Count); Assert.AreEqual(2, s.CreateQuery("from Foo foo").List().Count); Assert.AreEqual(1, s.CreateFilter(baz.FooArray, "").List().Count); @@ -2521,10 +2521,10 @@ if (!(Dialect is Oracle9Dialect) && !(Dialect is Oracle8iDialect)) { s.CreateQuery( - "select count(*) from Bar as bar, bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)"). + "select count(*) from Bar as bar join bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)"). List(); s.CreateQuery( - "select max( elements(bar.Baz.FooArray) ) from Bar as bar, bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)") + "select max( elements(bar.Baz.FooArray) ) from Bar as bar join bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)") .List(); s.CreateQuery( "select count(*) from Bar as bar left outer join bar.Component.Glarch.ProxyArray as pg where '1' in (from g in bar.Component.Glarch.ProxyArray)") @@ -2547,8 +2547,8 @@ s.CreateQuery( "select baz.Name from Bar bar join bar.Baz baz left outer join baz.FooSet foo where baz.Name = bar.String").List(); - s.CreateQuery("select baz.Name from Bar bar, bar.Baz baz, baz.FooSet foo where baz.Name = bar.String").List(); - s.CreateQuery("SELECT baz.Name FROM Bar AS bar, bar.Baz AS baz, baz.FooSet AS foo WHERE baz.Name = bar.String").List(); + s.CreateQuery("select baz.Name from Bar bar join bar.Baz baz join baz.FooSet foo where baz.Name = bar.String").List(); + s.CreateQuery("SELECT baz.Name FROM Bar AS bar join bar.Baz AS baz join baz.FooSet AS foo WHERE baz.Name = bar.String").List(); s.CreateQuery( "select baz.Name from Bar bar left join bar.Baz baz left join baz.FooSet foo where baz.Name = bar.String").List(); @@ -2565,10 +2565,10 @@ s.CreateQuery("select foo from bar in class Bar inner join bar.Baz.FooSet as foo").List(); s.CreateQuery( - "select bar.String, foo.String from bar in class Bar, bar.Baz as baz, elements(baz.FooSet) as foo where baz.Name = 'name'") + "select bar.String, foo.String from bar in class Bar join bar.Baz as baz, elements(baz.FooSet) as foo where baz.Name = 'name'") .List(); - s.CreateQuery("select foo from bar in class Bar, bar.Baz as baz, baz.FooSet as foo").List(); - s.CreateQuery("select foo from bar in class Bar, bar.Baz.FooSet as foo").List(); + s.CreateQuery("select foo from bar in class Bar join bar.Baz as baz join baz.FooSet as foo").List(); + s.CreateQuery("select foo from bar in class Bar join bar.Baz.FooSet as foo").List(); Assert.AreEqual(1, s.CreateQuery("from Bar bar join bar.Baz.FooArray foo").List().Count); Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-13 06:36:41 UTC (rev 4287) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-13 09:17:42 UTC (rev 4288) @@ -374,9 +374,9 @@ 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 join m.Details d WHERE d.I=5").Enumerable(); + s.CreateQuery("SELECT m FROM m in CLASS NHibernate.DomainModel.Master join m.Details d WHERE d.I=5").List(); + s.CreateQuery("SELECT m.id FROM m IN CLASS NHibernate.DomainModel.Master join m.Details d 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: <aye...@us...> - 2009-05-13 06:36:50
|
Revision: 4287 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4287&view=rev Author: ayenderahien Date: 2009-05-13 06:36:41 +0000 (Wed, 13 May 2009) Log Message: ----------- fixing whitespace issues Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 05:58:35 UTC (rev 4286) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 06:36:41 UTC (rev 4287) @@ -33,22 +33,22 @@ totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else if (log.IsDebugEnabled) - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); - } - if (currentBatch.CountOfCommands >= batchSize) + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + } + else if (log.IsDebugEnabled) + { + log.Debug("Adding to batch:" + lineWithParameters); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); + } + if (currentBatch.CountOfCommands >= batchSize) + { DoExecuteBatch(batchUpdate); } } @@ -58,15 +58,15 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - } - int rowsAffected = currentBatch.ExecuteNonQuery(); + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 05:58:45
|
Revision: 4286 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4286&view=rev Author: fabiomaulo Date: 2009-05-13 05:58:35 +0000 (Wed, 13 May 2009) Log Message: ----------- Fixing ignored mappings nodes (fixed) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs trunk/nhibernate/src/NHibernate/Mapping/Component.cs trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -96,13 +96,13 @@ model.AddJoin(join); } else if ("subclass".Equals(name)) - new SubclassBinder(this).HandleSubclass(model, subnode); + new SubclassBinder(this).HandleSubclass(model, subnode, inheritedMetas); else if ("joined-subclass".Equals(name)) - new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode); + new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, inheritedMetas); else if ("union-subclass".Equals(name)) - new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode); + new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, inheritedMetas); else if ("filter".Equals(name)) ParseFilter(subnode, model); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -2,6 +2,7 @@ using NHibernate.Mapping; using NHibernate.Persister.Entity; +using System.Collections.Generic; namespace NHibernate.Cfg.XmlHbmBinding { @@ -17,18 +18,18 @@ { } - public void Bind(XmlNode node) + public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas) { PersistentClass superModel = GetSuperclass(node); - HandleJoinedSubclass(superModel, node); + HandleJoinedSubclass(superModel, node, inheritedMetas); } - public void HandleJoinedSubclass(PersistentClass model, XmlNode subnode) + public void HandleJoinedSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas) { JoinedSubclass subclass = new JoinedSubclass(model); - BindClass(subnode, null, subclass, EmptyMeta); - + BindClass(subnode, null, subclass, inheritedMetas); + inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <joined-subclass> // joined subclass if (subclass.EntityPersisterClass == null) subclass.RootClazz.EntityPersisterClass = typeof(JoinedSubclassEntityPersister); @@ -70,7 +71,7 @@ mytable.AddCheckConstraint(chNode.Value); // properties - PropertiesFromXML(subnode, subclass, EmptyMeta); + PropertiesFromXML(subnode, subclass, inheritedMetas); model.AddSubclass(subclass); mappings.AddClass(subclass); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -33,9 +33,9 @@ AddTypeDefs(mappingSchema); AddRootClasses(node, inheritedMetas); - AddSubclasses(node); - AddJoinedSubclasses(node); - AddUnionSubclasses(node); + AddSubclasses(node, inheritedMetas); + AddJoinedSubclasses(node, inheritedMetas); + AddUnionSubclasses(node, inheritedMetas); AddQueries(mappingSchema); AddSqlQueries(mappingSchema); @@ -73,28 +73,28 @@ binder.Bind(node, Deserialize<HbmClass>(node), inheritedMetas); } - private void AddUnionSubclasses(XmlNode parentNode) + private void AddUnionSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas) { UnionSubclassBinder binder = new UnionSubclassBinder(this, namespaceManager, dialect); foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsUnionSubclass, namespaceManager)) - binder.Bind(node); + binder.Bind(node, inheritedMetas); } - private void AddJoinedSubclasses(XmlNode parentNode) + private void AddJoinedSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas) { JoinedSubclassBinder binder = new JoinedSubclassBinder(this, namespaceManager, dialect); foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsJoinedSubclass, namespaceManager)) - binder.Bind(node); + binder.Bind(node, inheritedMetas); } - private void AddSubclasses(XmlNode parentNode) + private void AddSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas) { SubclassBinder binder = new SubclassBinder(this, namespaceManager, dialect); foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsSubclass, namespaceManager)) - binder.Bind(node); + binder.Bind(node, inheritedMetas); } private void AddQueries(HbmMapping mappingSchema) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Xml; using NHibernate.Mapping; @@ -17,25 +18,27 @@ { } - public void Bind(XmlNode node) + public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas) { PersistentClass superModel = GetSuperclass(node); - HandleSubclass(superModel, node); + HandleSubclass(superModel, node, inheritedMetas); } - public void HandleSubclass(PersistentClass model, XmlNode subnode) + public void HandleSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas) { Subclass subclass = new SingleTableSubclass(model); - BindClass(subnode, null, subclass, EmptyMeta); + BindClass(subnode, null, subclass, inheritedMetas); + inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <subclass> + if (subclass.EntityPersisterClass == null) subclass.RootClazz.EntityPersisterClass = typeof(SingleTableEntityPersister); log.InfoFormat("Mapping subclass: {0} -> {1}", subclass.EntityName, subclass.Table.Name); // properties - PropertiesFromXML(subnode, subclass, EmptyMeta); + PropertiesFromXML(subnode, subclass, inheritedMetas); model.AddSubclass(subclass); mappings.AddClass(subclass); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Xml; using NHibernate.Mapping; using NHibernate.Persister.Entity; @@ -16,17 +17,18 @@ { } - public void Bind(XmlNode node) + public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas) { PersistentClass superModel = GetSuperclass(node); - HandleUnionSubclass(superModel, node); + HandleUnionSubclass(superModel, node, inheritedMetas); } - public void HandleUnionSubclass(PersistentClass model, XmlNode subnode) + public void HandleUnionSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas) { - UnionSubclass unionSubclass = new UnionSubclass(model); + var unionSubclass = new UnionSubclass(model); - BindClass(subnode, null, unionSubclass, EmptyMeta); + BindClass(subnode, null, unionSubclass, inheritedMetas); + inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <union-subclass> // union subclass if (unionSubclass.EntityPersisterClass == null) @@ -47,7 +49,7 @@ log.InfoFormat("Mapping union-subclass: {0} -> {1}", unionSubclass.EntityName, unionSubclass.Table.Name); // properties - PropertiesFromXML(subnode, unionSubclass, EmptyMeta); + PropertiesFromXML(subnode, unionSubclass, inheritedMetas); model.AddSubclass(unionSubclass); mappings.AddClass(unionSubclass); Modified: trunk/nhibernate/src/NHibernate/Mapping/Component.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -11,7 +11,7 @@ /// etc. /// </summary> [Serializable] - public class Component : SimpleValue + public class Component : SimpleValue, IMetaAttributable { private readonly List<Property> properties = new List<Property>(); private System.Type componentClass; @@ -320,5 +320,16 @@ } public IDictionary<string, MetaAttribute> MetaAttributes { get; set; } + + public MetaAttribute GetMetaAttribute(string attributeName) + { + if (MetaAttributes == null) + { + return null; + } + MetaAttribute result; + MetaAttributes.TryGetValue(attributeName, out result); + return result; + } } } Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -206,6 +206,10 @@ public MetaAttribute GetMetaAttribute(string attributeName) { + if(metaAttributes == null) + { + return null; + } MetaAttribute result; metaAttributes.TryGetValue(attributeName, out result); return result; Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-13 05:44:30 UTC (rev 4285) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-13 05:58:35 UTC (rev 4286) @@ -76,6 +76,86 @@ } [Test] + public void NonMutatedInheritance() + { + PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked"); + MetaAttribute metaAttribute = cm.GetMetaAttribute("globalmutated"); + + Assert.That(metaAttribute, Is.Not.Null); + /*assertEquals( metaAttribute.getValues().size(), 2 ); + assertEquals( "top level", metaAttribute.getValues().get(0) );*/ + Assert.That(metaAttribute.Value, Is.EqualTo("wicked level")); + + Property property = cm.GetProperty("Component"); + MetaAttribute propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 3 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level")); + + var component = (Component)property.Value; + property = component.GetProperty("X"); + propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount x level")); + + property = cm.GetProperty("SortedEmployee"); + propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 3 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("sortedemployee level")); + + property = cm.GetProperty("AnotherSet"); + propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 2 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level")); + + var bag = (Bag)property.Value; + component = (Component)bag.Element; + + Assert.That(component.MetaAttributes.Count, Is.EqualTo(4)); + + metaAttribute = component.GetMetaAttribute("globalmutated"); + /*assertEquals( metaAttribute.getValues().size(), 3 ); + assertEquals( "top level", metaAttribute.getValues().get(0) ); + assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/ + Assert.That(metaAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite level")); + + property = component.GetProperty("Emp"); + propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property emp level")); + + property = component.GetProperty("Empinone"); + propertyAttribute = property.GetMetaAttribute("globalmutated"); + + Assert.That(propertyAttribute, Is.Not.Null); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/ + Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property empinone level")); + } + + [Test] public void Comparator() { PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-13 05:44:37
|
Revision: 4285 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4285&view=rev Author: ayenderahien Date: 2009-05-13 05:44:30 +0000 (Wed, 13 May 2009) Log Message: ----------- Minor patch from James Lanng, adding missing [Test] attribute to a test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs 2009-05-13 05:29:16 UTC (rev 4284) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs 2009-05-13 05:44:30 UTC (rev 4285) @@ -262,6 +262,7 @@ testData.Release(); } + [Test] public void ManyToManyFilterOnCriteria() { TestData testData = new TestData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-13 05:29:28
|
Revision: 4284 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4284&view=rev Author: ayenderahien Date: 2009-05-13 05:29:16 +0000 (Wed, 13 May 2009) Log Message: ----------- only do the log preparation if either logger wants it Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-12 15:29:32 UTC (rev 4283) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 05:29:16 UTC (rev 4284) @@ -32,19 +32,23 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + } + else if (log.IsDebugEnabled) + { + log.Debug("Adding to batch:" + lineWithParameters); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); + } + if (currentBatch.CountOfCommands >= batchSize) { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else if (log.IsDebugEnabled) - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); - if (currentBatch.CountOfCommands >= batchSize) - { DoExecuteBatch(batchUpdate); } } @@ -54,12 +58,15 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - int rowsAffected = currentBatch.ExecuteNonQuery(); + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-12 15:29:39
|
Revision: 4283 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4283&view=rev Author: fabiomaulo Date: 2009-05-12 15:29:32 +0000 (Tue, 12 May 2009) Log Message: ----------- Fixing ignored mappings nodes Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs trunk/nhibernate/src/NHibernate/Mapping/Component.cs trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmTimestamp : AbstractDecoratable + { + protected override HbmMeta[] GetMetadataField() + { + return meta; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmVersion : AbstractDecoratable + { + protected override HbmMeta[] GetMetadataField() + { + return meta; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -196,5 +196,47 @@ } return map; } + + public static IDictionary<string, MetaAttribute> GetMetas(XmlNodeList nodes, IDictionary<string, MetaAttribute> inheritedMeta) + { + return GetMetas(nodes, inheritedMeta, false); + } + + public static IDictionary<string, MetaAttribute> GetMetas(XmlNodeList nodes, IDictionary<string, MetaAttribute> inheritedMeta, bool onlyInheritable) + { + var map = new Dictionary<string, MetaAttribute>(inheritedMeta); + foreach (XmlNode metaNode in nodes) + { + if(metaNode.Name != "meta") + { + continue; + } + var inheritableValue = GetAttributeValue(metaNode, "inherit"); + bool inheritable = inheritableValue != null ? IsTrue(inheritableValue) : false; + if (onlyInheritable & !inheritable) + { + continue; + } + string name = GetAttributeValue(metaNode, "attribute"); + + MetaAttribute meta; + MetaAttribute inheritedAttribute; + map.TryGetValue(name, out meta); + inheritedMeta.TryGetValue(name, out inheritedAttribute); + if (meta == null) + { + meta = new MetaAttribute(name); + map[name] = meta; + } + else if (meta == inheritedAttribute) + { + meta = new MetaAttribute(name); + map[name] = meta; + } + meta.AddValue(metaNode.InnerText); + } + return map; + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -54,8 +54,8 @@ CollectionBinder collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) { - Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, - propertyName, model, model.MappedClass); + Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, propertyName, model, + model.MappedClass, inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -86,13 +86,13 @@ // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName); value = new Component(model); - BindComponent(subnode, (Component)value, reflectedClass, entityName, propertyName, subpath, true); + BindComponent(subnode, (Component) value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas); } else if ("join".Equals(name)) { Join join = new Join(); join.PersistentClass = model; - BindJoin(subnode, join); + BindJoin(subnode, join, inheritedMetas); model.AddJoin(join); } else if ("subclass".Equals(name)) @@ -125,7 +125,7 @@ if (value != null) { - Property property = CreateProperty(value, propertyName, model.ClassName, subnode); + Property property = CreateProperty(value, propertyName, model.ClassName, subnode, inheritedMetas); if (!mutable) property.IsUpdateable = false; if (naturalId) @@ -296,7 +296,7 @@ return null; } - private void BindJoin(XmlNode node, Join join) + private void BindJoin(XmlNode node, Join join, IDictionary<string, MetaAttribute> inheritedMetas) { PersistentClass persistentClass = join.PersistentClass; String path = persistentClass.EntityName; @@ -351,8 +351,9 @@ var collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) { - Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, - propertyName, persistentClass, persistentClass.MappedClass); + Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, propertyName, + persistentClass, persistentClass.MappedClass, + inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -378,13 +379,14 @@ string subpath = StringHelper.Qualify(path, propertyName); value = new Component(join); BindComponent(subnode, (Component) value, join.PersistentClass.MappedClass, join.PersistentClass.ClassName, - propertyName, subpath, true); + propertyName, subpath, true, inheritedMetas); break; } } if (value != null) { - Mapping.Property prop = CreateProperty(value, propertyName, persistentClass.MappedClass.AssemblyQualifiedName, subnode); + var prop = CreateProperty(value, propertyName, persistentClass.MappedClass.AssemblyQualifiedName, subnode, + inheritedMetas); prop.IsOptional = join.IsOptional; join.AddProperty(prop); } @@ -543,12 +545,16 @@ } protected void BindComponent(XmlNode node, Component model, System.Type reflectedClass, - string className, string parentProperty, string path, bool isNullable) + string className, string parentProperty, string path, bool isNullable, + IDictionary<string, MetaAttribute> inheritedMetas) { bool isIdentifierMapper = false; model.RoleName = path; + inheritedMetas = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); + model.MetaAttributes = inheritedMetas; + XmlAttribute classNode = node.Attributes["class"]; if (classNode != null) @@ -595,8 +601,8 @@ if (binder.CanCreate(name)) { - Mapping.Collection collection = binder.Create(name, subnode, className, - subpath, model.Owner, model.ComponentClass); + Mapping.Collection collection = binder.Create(name, subnode, className, subpath, model.Owner, model.ComponentClass, + inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -629,14 +635,14 @@ : GetPropertyType(subnode, model.ComponentClass, propertyName); value = new Component(model); - BindComponent(subnode, (Component) value, subreflectedClass, className, propertyName, subpath, isNullable); + BindComponent(subnode, (Component) value, subreflectedClass, className, propertyName, subpath, isNullable, inheritedMetas); } else if ("parent".Equals(name)) model.ParentProperty = propertyName; if (value != null) { - Property property = CreateProperty(value, propertyName, model.ComponentClassName, subnode); + Property property = CreateProperty(value, propertyName, model.ComponentClassName, subnode, inheritedMetas); if (isIdentifierMapper) { property.IsInsertable = false; @@ -648,7 +654,7 @@ } protected Property CreateProperty(IValue value, string propertyName, string className, - XmlNode subnode) + XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas) { if (string.IsNullOrEmpty(propertyName)) { @@ -668,14 +674,13 @@ } value.CreateForeignKey(); - Property prop = new Property(); - prop.Value = value; - BindProperty(subnode, prop); + var prop = new Property {Value = value}; + BindProperty(subnode, prop, inheritedMetas); return prop; } - protected void BindProperty(XmlNode node, Mapping.Property property) + protected void BindProperty(XmlNode node, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { string propName = XmlHelper.GetAttributeValue(node, "name"); property.Name = propName; @@ -742,7 +747,7 @@ log.Debug(msg); } - property.MetaAttributes = GetMetas(node); + property.MetaAttributes = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); } protected static PropertyGeneration ParsePropertyGeneration(string name) @@ -946,25 +951,6 @@ model.PropertyName = node.Attributes["name"].Value; } - protected IDictionary<string, MetaAttribute> GetMetas(XmlNode node) - { - Dictionary<string, MetaAttribute> map = new Dictionary<string, MetaAttribute>(); - - foreach (XmlNode metaNode in node.SelectNodes(HbmConstants.nsMeta, namespaceManager)) - { - string name = metaNode.Attributes["attribute"].Value; - MetaAttribute meta; - if (!map.TryGetValue(name, out meta)) - { - meta = new MetaAttribute(name); - map[name] = meta; - } - meta.AddValue(metaNode.InnerText); - } - - return map; - } - protected System.Type GetPropertyType(XmlNode definingNode, System.Type containingType, string propertyName) { if (definingNode.Attributes["class"] != null) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -38,65 +38,65 @@ } public Mapping.Collection Create(string xmlTagName, XmlNode node, string className, - string path, PersistentClass owner, System.Type containingType) + string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { CreateCollectionCommand command = createCollectionCommands[xmlTagName]; - return command(node, className, path, owner, containingType); + return command(node, className, path, owner, containingType, inheritedMetas); } private Mapping.Collection CreateMap(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Map map = new Map(owner); - BindCollection(node, map, prefix, path, containingType); + BindCollection(node, map, prefix, path, containingType, inheritedMetas); return map; } private Mapping.Collection CreateSet(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Set setCollection = new Set(owner); - BindCollection(node, setCollection, prefix, path, containingType); + BindCollection(node, setCollection, prefix, path, containingType, inheritedMetas); return setCollection; } private Mapping.Collection CreateList(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { List list = new List(owner); - BindCollection(node, list, prefix, path, containingType); + BindCollection(node, list, prefix, path, containingType, inheritedMetas); return list; } private Mapping.Collection CreateBag(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Bag bag = new Bag(owner); - BindCollection(node, bag, prefix, path, containingType); + BindCollection(node, bag, prefix, path, containingType, inheritedMetas); return bag; } private Mapping.Collection CreateIdentifierBag(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { IdentifierBag bag = new IdentifierBag(owner); - BindCollection(node, bag, prefix, path, containingType); + BindCollection(node, bag, prefix, path, containingType, inheritedMetas); return bag; } private Mapping.Collection CreateArray(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Array array = new Array(owner); - BindArray(node, array, prefix, path, containingType); + BindArray(node, array, prefix, path, containingType, inheritedMetas); return array; } private Mapping.Collection CreatePrimitiveArray(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { PrimitiveArray array = new PrimitiveArray(owner); - BindArray(node, array, prefix, path, containingType); + BindArray(node, array, prefix, path, containingType,inheritedMetas); return array; } @@ -105,7 +105,7 @@ /// was added in NH to allow for reflection related to generic types. /// </remarks> private void BindCollection(XmlNode node, Mapping.Collection model, string className, - string path, System.Type containingType) + string path, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { // ROLENAME model.Role = StringHelper.Qualify(className, path); @@ -253,19 +253,19 @@ //set up second pass if (model is List) - AddListSecondPass(node, (List)model); + AddListSecondPass(node, (List)model, inheritedMetas); else if (model is Map) - AddMapSecondPass(node, (Map)model); + AddMapSecondPass(node, (Map)model, inheritedMetas); else if (model is Set) - AddSetSecondPass(node, (Set)model); + AddSetSecondPass(node, (Set)model, inheritedMetas); else if (model is IdentifierCollection) - AddIdentifierCollectionSecondPass(node, (IdentifierCollection)model); + AddIdentifierCollectionSecondPass(node, (IdentifierCollection)model, inheritedMetas); else - AddCollectionSecondPass(node, model); + AddCollectionSecondPass(node, model, inheritedMetas); foreach (XmlNode filter in node.SelectNodes(HbmConstants.nsFilter, namespaceManager)) ParseFilter(filter, model); @@ -284,9 +284,9 @@ /// Called for arrays and primitive arrays /// </remarks> private void BindArray(XmlNode node, Array model, string prefix, string path, - System.Type containingType) + System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollection(node, model, prefix, path, containingType); + BindCollection(node, model, prefix, path, containingType, inheritedMetas); XmlAttribute att = node.Attributes["element-class"]; @@ -327,52 +327,52 @@ } } - private void AddListSecondPass(XmlNode node, List model) + private void AddListSecondPass(XmlNode node, List model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindListSecondPass(node, model, persistentClasses); + BindListSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddMapSecondPass(XmlNode node, Map model) + private void AddMapSecondPass(XmlNode node, Map model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindMapSecondPass(node, model, persistentClasses); + BindMapSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddSetSecondPass(XmlNode node, Set model) + private void AddSetSecondPass(XmlNode node, Set model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindSetSecondPass(node, model, persistentClasses); + BindSetSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model) + private void AddIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindIdentifierCollectionSecondPass(node, model, persistentClasses); + BindIdentifierCollectionSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddCollectionSecondPass(XmlNode node, Mapping.Collection model) + private void AddCollectionSecondPass(XmlNode node, Mapping.Collection model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } @@ -436,9 +436,9 @@ } private void BindListSecondPass(XmlNode node, List model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); XmlNode subnode = node.SelectSingleNode(HbmConstants.nsListIndex, namespaceManager); if (subnode == null) { subnode = node.SelectSingleNode(HbmConstants.nsIndex, namespaceManager); } @@ -459,9 +459,9 @@ } private void BindIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model, - IDictionary<string, PersistentClass> persitentClasses) + IDictionary<string, PersistentClass> persitentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persitentClasses); + BindCollectionSecondPass(node, model, persitentClasses, inheritedMetas); XmlNode subnode = node.SelectSingleNode(HbmConstants.nsCollectionId, namespaceManager); SimpleValue id = new SimpleValue(model.CollectionTable); @@ -481,9 +481,9 @@ } private void BindSetSecondPass(XmlNode node, Set model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); if (!model.IsOneToMany) model.CreatePrimaryKey(); @@ -492,13 +492,10 @@ /// <summary> /// Called for Maps /// </summary> - /// <param name="node"></param> - /// <param name="model"></param> - /// <param name="persistentClasses"></param> private void BindMapSecondPass(XmlNode node, Map model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); foreach (XmlNode subnode in node.ChildNodes) { @@ -525,7 +522,7 @@ else if ("composite-index".Equals(name) || "composite-map-key".Equals(name)) { Component component = new Component(model); - BindComponent(subnode, component, null, null, null, model.Role + ".index", model.IsOneToMany); + BindComponent(subnode, component, null, null, null, model.Role + ".index", model.IsOneToMany,inheritedMetas); model.Index = component; } else if ("index-many-to-any".Equals(name)) @@ -541,7 +538,7 @@ /// Called for all collections /// </remarks> private void BindCollectionSecondPass(XmlNode node, Mapping.Collection model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { if (model.IsOneToMany) { @@ -614,7 +611,7 @@ { Component element = new Component(model); model.Element = element; - BindComponent(subnode, element, null, null, null, model.Role+ ".element", true); + BindComponent(subnode, element, null, null, null, model.Role+ ".element", true, inheritedMetas); } else if ("many-to-any".Equals(name)) { @@ -673,6 +670,6 @@ } private delegate Mapping.Collection CreateCollectionCommand(XmlNode node, string className, - string path, PersistentClass owner, System.Type containingType); + string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas); } } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -48,8 +48,8 @@ new ClassIdBinder(this).BindId(classSchema.Id, rootClass, table); new ClassCompositeIdBinder(this).BindCompositeId(classSchema.CompositeId, rootClass); new ClassDiscriminatorBinder(this).BindDiscriminator(classSchema.discriminator, rootClass, table); - BindTimestamp(classSchema.Timestamp, rootClass, table); - BindVersion(classSchema.Version, rootClass, table); + BindTimestamp(classSchema.Timestamp, rootClass, table, inheritedMetas); + BindVersion(classSchema.Version, rootClass, table, inheritedMetas); rootClass.CreatePrimaryKey(dialect); @@ -65,7 +65,7 @@ return mappings.NamingStrategy.TableName(classSchema.table.Trim()); } - private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table) + private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas) { if (timestampSchema == null) return; @@ -78,8 +78,8 @@ if (!simpleValue.IsTypeSpecified) simpleValue.TypeName = NHibernateUtil.Timestamp.Name; - Mapping.Property property = new Mapping.Property(simpleValue); - BindProperty(timestampSchema, property); + var property = new Property(simpleValue); + BindProperty(timestampSchema, property, inheritedMetas); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make @@ -128,7 +128,7 @@ column.SqlType = null; } - private void BindProperty(HbmTimestamp timestampSchema, Mapping.Property property) + private void BindProperty(HbmTimestamp timestampSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { property.Name = timestampSchema.name; @@ -158,7 +158,7 @@ property.IsUpdateable = false; } - property.MetaAttributes = new Dictionary<string, MetaAttribute>(); + property.MetaAttributes = GetMetas(timestampSchema, inheritedMetas); LogMappedProperty(property); } @@ -178,7 +178,7 @@ } } - private void BindVersion(HbmVersion versionSchema, PersistentClass rootClass, Table table) + private void BindVersion(HbmVersion versionSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas) { if (versionSchema == null) return; @@ -190,8 +190,8 @@ if (!simpleValue.IsTypeSpecified) simpleValue.TypeName = NHibernateUtil.Int32.Name; - Mapping.Property property = new Mapping.Property(simpleValue); - BindProperty(versionSchema, property); + var property = new Property(simpleValue); + BindProperty(versionSchema, property, inheritedMetas); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make @@ -249,7 +249,7 @@ } } - private void BindProperty(HbmVersion versionSchema, Mapping.Property property) + private void BindProperty(HbmVersion versionSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { property.Name = versionSchema.name; @@ -279,7 +279,7 @@ property.IsUpdateable = false; } - property.MetaAttributes = new Dictionary<string, MetaAttribute>(); + property.MetaAttributes = GetMetas(versionSchema, inheritedMetas); LogMappedProperty(property); } Modified: trunk/nhibernate/src/NHibernate/Mapping/Component.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -318,5 +318,7 @@ { return GetType().FullName + '(' + StringHelper.CollectionToString(properties) + ')'; } + + public IDictionary<string, MetaAttribute> MetaAttributes { get; set; } } } Modified: trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -13,8 +13,8 @@ /// <summary> /// Retrieve the <see cref="MetaAttribute"/> /// </summary> - /// <param name="name">The attribute name</param> + /// <param name="attributeName">The attribute name</param> /// <returns>The <see cref="MetaAttribute"/> if exists; null otherwise</returns> - MetaAttribute GetMetaAttribute(string name); + MetaAttribute GetMetaAttribute(string attributeName); } } Modified: trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -969,12 +969,12 @@ } } - public MetaAttribute GetMetaAttribute(string name) + public MetaAttribute GetMetaAttribute(string attributeName) { if (metaAttributes == null) return null; MetaAttribute result; - metaAttributes.TryGetValue(name, out result); + metaAttributes.TryGetValue(attributeName, out result); return result; } Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -204,9 +204,11 @@ set { metaAttributes = value; } } - public MetaAttribute GetMetaAttribute(string name) + public MetaAttribute GetMetaAttribute(string attributeName) { - return metaAttributes[name]; + MetaAttribute result; + metaAttributes.TryGetValue(attributeName, out result); + return result; } public bool IsValid(IMapping mapping) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-12 15:29:32 UTC (rev 4283) @@ -455,6 +455,8 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> + <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> + <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -36,6 +36,43 @@ Assert.That(m, Is.Not.Null); Assert.That(cm.GetMetaAttribute("global"), Is.Not.Null); Assert.That(cm.GetMetaAttribute("globalnoinherit"), Is.Null); + + MetaAttribute metaAttribute = cm.GetMetaAttribute("implements"); + Assert.That(metaAttribute, Is.Not.Null); + Assert.That(metaAttribute.Name, Is.EqualTo("implements")); + Assert.That(metaAttribute.IsMultiValued); + var values = metaAttribute.Values; + Assert.That(values.Count, Is.EqualTo(3)); + Assert.That(values[0], Is.EqualTo("IObserver")); + Assert.That(values[1], Is.EqualTo("IObserver")); + Assert.That(values[2], Is.EqualTo("Foo.BogusVisitor")); + + foreach (var element in cm.PropertyIterator) + { + var ma = element.MetaAttributes; + Assert.That(ma, Is.Not.Null); + Assert.That(element.GetMetaAttribute("global"), Is.Not.Null,"inherited attribute missing for prop {0}",element.Name); + MetaAttribute metaAttribute2 = element.GetMetaAttribute("implements"); + Assert.That(metaAttribute2, Is.Not.Null); + Assert.That(element.GetMetaAttribute("globalnoinherit"), Is.Null); + } + + Property prop = cm.GetProperty("Component"); + var map = prop.MetaAttributes; + Assert.That(map, Is.Not.Null); + Assert.That(prop.GetMetaAttribute("global"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("componentonly"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("allcomponent"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("globalnoinherit"), Is.Null); + + MetaAttribute compimplements = prop.GetMetaAttribute("implements"); + Assert.That(compimplements, Is.Not.Null); + Assert.That(compimplements.Value, Is.EqualTo("AnotherInterface")); + + Property xp = ((Component)prop.Value).GetProperty("X"); + MetaAttribute propximplements = xp.GetMetaAttribute("implements"); + Assert.That(propximplements, Is.Not.Null); + Assert.That(propximplements.Value, Is.EqualTo("AnotherInterface")); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -7,6 +7,7 @@ { public int Id { get; set; } public int VersionProp { get; set; } + public MonetaryAmount Component { get; set; } public ISet SortedEmployee { get; set; } public IList AnotherSet { get; set; } } Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-12 15:29:32 UTC (rev 4283) @@ -20,7 +20,7 @@ <generator class="assigned"/> </id> <version name="VersionProp"/> - <component name="component" class="MonetaryAmount"> + <component name="Component" class="MonetaryAmount"> <meta attribute="componentonly" inherit="true"/> <meta attribute="implements">AnotherInterface</meta> <meta attribute="allcomponent"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-12 04:53:32
|
Revision: 4282 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4282&view=rev Author: fabiomaulo Date: 2009-05-12 04:53:16 +0000 (Tue, 12 May 2009) Log Message: ----------- Fixing ignored mappings nodes Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapping.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs trunk/nhibernate/src/NHibernate/Mapping/Collection.cs trunk/nhibernate/src/NHibernate/Mapping/MetaAttribute.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IDecoratable.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using NHibernate.Mapping; +using NHibernate.Util; + +namespace NHibernate.Cfg.MappingSchema +{ + [Serializable] + public abstract class AbstractDecoratable : IDecoratable + { + private static readonly IDictionary<string, MetaAttribute> EmptyMetaData = new CollectionHelper.EmptyMapClass<string, MetaAttribute>(); + + private IDictionary<string, MetaAttribute> mappedMetaData; + private IDictionary<string, MetaAttribute> inheritableMetaData; + + public virtual IDictionary<string, MetaAttribute> MappedMetaData + { + get + { + if (mappedMetaData == null) + { + CreateMappedMetadata(GetMetadataField()); + } + return mappedMetaData; + } + } + + public IDictionary<string, MetaAttribute> InheritableMetaData + { + get + { + if (mappedMetaData == null) + { + CreateMappedMetadata(GetMetadataField()); + } + return inheritableMetaData; + } + } + + protected void CreateMappedMetadata(HbmMeta[] metadatas) + { + if (metadatas == null) + { + mappedMetaData = EmptyMetaData; + inheritableMetaData = EmptyMetaData; + return; + } + mappedMetaData = new Dictionary<string, MetaAttribute>(10); + inheritableMetaData = new Dictionary<string, MetaAttribute>(10); + + foreach (var hbmMeta in metadatas) + { + MetaAttribute attribute; + if (!mappedMetaData.TryGetValue(hbmMeta.attribute, out attribute)) + { + attribute = new MetaAttribute(hbmMeta.attribute); + mappedMetaData[hbmMeta.attribute] = attribute; + if(hbmMeta.inherit) + { + inheritableMetaData[hbmMeta.attribute] = attribute; + } + } + if (hbmMeta.Text != null) + { + attribute.AddValue(string.Concat(hbmMeta.Text)); + } + } + } + + protected abstract HbmMeta[] GetMetadataField(); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -1,6 +1,8 @@ +using System; + namespace NHibernate.Cfg.MappingSchema { - partial class HbmClass + partial class HbmClass: AbstractDecoratable { public HbmId Id { @@ -21,5 +23,10 @@ { get { return Item1 as HbmTimestamp; } } + + protected override HbmMeta[] GetMetadataField() + { + return meta; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapping.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapping.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -1,6 +1,6 @@ namespace NHibernate.Cfg.MappingSchema { - partial class HbmMapping : HbmBase + partial class HbmMapping : AbstractDecoratable { public HbmDatabaseObject[] ListDatabaseObjects() { @@ -11,5 +11,10 @@ { return filterdef ?? new HbmFilterDef[0]; } + + protected override HbmMeta[] GetMetadataField() + { + return meta; + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IDecoratable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IDecoratable.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IDecoratable.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using NHibernate.Mapping; + +namespace NHibernate.Cfg.MappingSchema +{ + public interface IDecoratable + { + IDictionary<string, MetaAttribute> MappedMetaData { get; } + IDictionary<string, MetaAttribute> InheritableMetaData { get; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -1,18 +1,24 @@ using System; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Xml; using System.Xml.Serialization; using log4net; - +using NHibernate.Mapping; using NHibernate.Util; +using NHibernate.Cfg.MappingSchema; namespace NHibernate.Cfg.XmlHbmBinding { public abstract class Binder { protected static readonly ILog log = LogManager.GetLogger(typeof (Binder)); + + protected static readonly IDictionary<string, MetaAttribute> EmptyMeta = + new CollectionHelper.EmptyMapClass<string, MetaAttribute>(); + protected readonly Mappings mappings; protected Binder(Binder parent) @@ -147,5 +153,48 @@ XmlAttribute att = node.Attributes[attributeName]; return att != null ? att.Value : null; } + + public static IDictionary<string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary<string, MetaAttribute> inheritedMeta) + { + return GetMetas(decoratable, inheritedMeta, false); + } + + public static IDictionary<string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary<string, MetaAttribute> inheritedMeta, bool onlyInheritable) + { + if(decoratable == null) + { + return EmptyMeta; + } + var map = new Dictionary<string, MetaAttribute>(inheritedMeta); + + IDictionary<string, MetaAttribute> metaAttributes = onlyInheritable + ? decoratable.InheritableMetaData + : decoratable.MappedMetaData; + + foreach (var metaAttribute in metaAttributes) + { + string name = metaAttribute.Key; + + MetaAttribute meta; + MetaAttribute inheritedAttribute; + + map.TryGetValue(name, out meta); + inheritedMeta.TryGetValue(name, out inheritedAttribute); + + if (meta == null) + { + meta = new MetaAttribute(name); + map[name] = meta; + } + else if (meta == inheritedAttribute) + { + // overriding inherited meta attribute. + meta = new MetaAttribute(name); + map[name] = meta; + } + meta.AddValues(metaAttribute.Value.Values); + } + return map; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -16,26 +16,26 @@ protected readonly Dialect.Dialect dialect; protected readonly XmlNamespaceManager namespaceManager; - public ClassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect) + protected ClassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect) : base(parent) { this.dialect = dialect; this.namespaceManager = namespaceManager; } - public ClassBinder(ClassBinder parent) + protected ClassBinder(ClassBinder parent) : base(parent) { dialect = parent.dialect; namespaceManager = parent.namespaceManager; } - protected void PropertiesFromXML(XmlNode node, PersistentClass model) + protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas) { - PropertiesFromXML(node, model, null, true, true, false); + PropertiesFromXML(node, model, inheritedMetas, null, true, true, false); } - protected void PropertiesFromXML(XmlNode node, PersistentClass model, UniqueKey uniqueKey, bool mutable, bool nullable, bool naturalId) + protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas, UniqueKey uniqueKey, bool mutable, bool nullable, bool naturalId) { string entityName = model.EntityName; @@ -119,7 +119,7 @@ mutableId = "true".Equals(subnode.Attributes["mutable"]); } - PropertiesFromXML(subnode, model, uk, mutableId, false, true); + PropertiesFromXML(subnode, model, inheritedMetas, uk, mutableId, false, true); table.AddUniqueKey(uk); } @@ -137,7 +137,7 @@ } } - protected void BindClass(XmlNode node, PersistentClass model) + protected void BindClass(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas) { // transfer an explicitly defined entity name // handle the lazy attribute @@ -160,10 +160,10 @@ BindXmlRepresentation(node, model); BindMapRepresentation(node, model); - BindPersistentClassCommonValues(node, model); + BindPersistentClassCommonValues(node, classMapping, model, inheritedMetas); } - private void BindPersistentClassCommonValues(XmlNode node, PersistentClass model) + private void BindPersistentClassCommonValues(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas) { // DISCRIMINATOR XmlAttribute discriminatorNode = node.Attributes["discriminator-value"]; @@ -201,7 +201,7 @@ model.OptimisticLockMode = GetOptimisticLockMode(olNode); // META ATTRIBUTES - model.MetaAttributes = GetMetas(node); + model.MetaAttributes = GetMetas(classMapping, inheritedMetas); // PERSISTER XmlAttribute persisterNode = node.Attributes["persister"]; Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -215,14 +215,7 @@ if (!sortedAtt.Value.Equals("natural")) { string comparatorClassName = FullQualifiedClassName(sortedAtt.Value, mappings); - try - { - model.Comparer = Activator.CreateInstance(ReflectHelper.ClassForName(comparatorClassName)); - } - catch - { - throw new MappingException("could not instantiate comparer class: " + comparatorClassName); - } + model.ComparerClassName = comparatorClassName; } } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -27,7 +27,7 @@ { JoinedSubclass subclass = new JoinedSubclass(model); - BindClass(subnode, subclass); + BindClass(subnode, null, subclass, EmptyMeta); // joined subclass if (subclass.EntityPersisterClass == null) @@ -70,7 +70,7 @@ mytable.AddCheckConstraint(chNode.Value); // properties - PropertiesFromXML(subnode, subclass); + PropertiesFromXML(subnode, subclass, EmptyMeta); model.AddSubclass(subclass); mappings.AddClass(subclass); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -23,13 +23,16 @@ public void Bind(XmlNode node) { - HbmMapping mappingSchema = Deserialize<HbmMapping>(node); + IDictionary<string, MetaAttribute> inheritedMetas = EmptyMeta; + var mappingSchema = Deserialize<HbmMapping>(node); + // get meta's from <hibernate-mapping> + inheritedMetas = GetMetas(mappingSchema, inheritedMetas, true); SetMappingsProperties(mappingSchema); AddFilterDefinitions(mappingSchema); AddTypeDefs(mappingSchema); - AddRootClasses(node); + AddRootClasses(node, inheritedMetas); AddSubclasses(node); AddJoinedSubclasses(node); AddUnionSubclasses(node); @@ -62,12 +65,12 @@ } } - private void AddRootClasses(XmlNode parentNode) + private void AddRootClasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas) { RootClassBinder binder = new RootClassBinder(this, namespaceManager, dialect); foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsClass, namespaceManager)) - binder.Bind(node, Deserialize<HbmClass>(node)); + binder.Bind(node, Deserialize<HbmClass>(node), inheritedMetas); } private void AddUnionSubclasses(XmlNode parentNode) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -13,10 +13,11 @@ { } - public void Bind(XmlNode node, HbmClass classSchema) + public void Bind(XmlNode node, HbmClass classSchema, IDictionary<string, MetaAttribute> inheritedMetas) { RootClass rootClass = new RootClass(); - BindClass(node, rootClass); + BindClass(node, classSchema, rootClass, inheritedMetas); + inheritedMetas = GetMetas(classSchema, inheritedMetas, true); // get meta's from <class> //TABLENAME string schema = classSchema.schema ?? mappings.SchemaName; @@ -51,7 +52,8 @@ BindVersion(classSchema.Version, rootClass, table); rootClass.CreatePrimaryKey(dialect); - PropertiesFromXML(node, rootClass); + + PropertiesFromXML(node, rootClass, inheritedMetas); mappings.AddClass(rootClass); } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -27,7 +27,7 @@ { Subclass subclass = new SingleTableSubclass(model); - BindClass(subnode, subclass); + BindClass(subnode, null, subclass, EmptyMeta); if (subclass.EntityPersisterClass == null) subclass.RootClazz.EntityPersisterClass = typeof(SingleTableEntityPersister); @@ -35,7 +35,7 @@ log.InfoFormat("Mapping subclass: {0} -> {1}", subclass.EntityName, subclass.Table.Name); // properties - PropertiesFromXML(subnode, subclass); + PropertiesFromXML(subnode, subclass, EmptyMeta); model.AddSubclass(subclass); mappings.AddClass(subclass); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -26,7 +26,7 @@ { UnionSubclass unionSubclass = new UnionSubclass(model); - BindClass(subnode, unionSubclass); + BindClass(subnode, null, unionSubclass, EmptyMeta); // union subclass if (unionSubclass.EntityPersisterClass == null) @@ -47,7 +47,7 @@ log.InfoFormat("Mapping union-subclass: {0} -> {1}", unionSubclass.EntityName, unionSubclass.Table.Name); // properties - PropertiesFromXML(subnode, unionSubclass); + PropertiesFromXML(subnode, unionSubclass, EmptyMeta); model.AddSubclass(unionSubclass); mappings.AddClass(unionSubclass); Modified: trunk/nhibernate/src/NHibernate/Mapping/Collection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Collection.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Mapping/Collection.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -150,10 +150,27 @@ // both IComparer and IComparer<T>. public object Comparer { - get { return comparer; } + get + { + if (comparer == null && !string.IsNullOrEmpty(ComparerClassName)) + { + try + { + comparer = Activator.CreateInstance(ReflectHelper.ClassForName(ComparerClassName)); + } + catch + { + throw new MappingException("Could not instantiate comparator class [" + ComparerClassName + "] for collection " + Role); + } + } + return comparer; + } + set { comparer = value; } } + public string ComparerClassName { get; set; } + public bool IsLazy { get { return lazy; } Modified: trunk/nhibernate/src/NHibernate/Mapping/MetaAttribute.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/MetaAttribute.cs 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/Mapping/MetaAttribute.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -49,6 +49,11 @@ values.Add(value); } + public void AddValues(IEnumerable<string> range) + { + values.AddRange(range); + } + public override string ToString() { return string.Format("[{0}={1}]", name, CollectionPrinter.ToString(values)); Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-12 04:53:16 UTC (rev 4282) @@ -454,6 +454,8 @@ <Compile Include="Bytecode\HibernateByteCodeException.cs" /> <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> + <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> + <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -0,0 +1,51 @@ +using NHibernate.Cfg; +using NHibernate.Mapping; +using NUnit.Framework; + +namespace NHibernate.Test.MappingTest +{ + [TestFixture] + public class NonReflectiveBinderFixture + { + // so far we are using this test to check metadata + // TODO: fix the test to work without class implementations + // all infos coming from XML should be solved Mapping classes and not + // during parse. + + private Configuration cfg; + + [TestFixtureSetUp] + public void SetUp() + { + cfg = new Configuration() + .AddResource("NHibernate.Test.MappingTest.Wicked.hbm.xml", GetType().Assembly); + cfg.BuildMappings(); + } + + [TestFixtureTearDown] + public void TearDown() + { + cfg = null; + } + + [Test] + public void MetaInheritance() + { + PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked"); + var m = cm.MetaAttributes; + Assert.That(m, Is.Not.Null); + Assert.That(cm.GetMetaAttribute("global"), Is.Not.Null); + Assert.That(cm.GetMetaAttribute("globalnoinherit"), Is.Null); + } + + [Test] + public void Comparator() + { + PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked"); + + Property property = cm.GetProperty("SortedEmployee"); + var col = (Mapping.Collection)property.Value; + Assert.That(col.ComparerClassName, Text.StartsWith("NHibernate.Test.MappingTest.NonExistingComparator")); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-12 04:53:16 UTC (rev 4282) @@ -0,0 +1,25 @@ +using System.Collections; +using Iesi.Collections; + +namespace NHibernate.Test.MappingTest +{ + public class Wicked + { + public int Id { get; set; } + public int VersionProp { get; set; } + public ISet SortedEmployee { get; set; } + public IList AnotherSet { get; set; } + } + + public class MonetaryAmount + { + public string X { get; set; } + } + + public class Employee + { + public int Id { get; set; } + public string Emp { get; set; } + public Employee Empinone { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-12 04:53:16 UTC (rev 4282) @@ -0,0 +1,60 @@ +<?xml version="1.0"?> +<!-- Mapping document mainly used for testing non-reflective Binder + meta inheritance --> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" + assembly="NHibernate.Test" + namespace="NHibernate.Test.MappingTest"> + <meta attribute="global">global value</meta> + <meta attribute="globalnoinherit" inherit="false">only visible at top level</meta> + <meta attribute="globalmutated">top level</meta> + + <class name="Wicked" + table="WICKED" + schema="HR"> + <meta attribute="implements">IObserver</meta> + <meta attribute="implements">IObserver</meta> + <meta attribute="implements" inherit="false">Foo.BogusVisitor</meta> + <meta attribute="extends">AuditInfo</meta> + <meta attribute="globalmutated">wicked level</meta> + <id name="Id" + column="EMPLOYEE_ID"> + <generator class="assigned"/> + </id> + <version name="VersionProp"/> + <component name="component" class="MonetaryAmount"> + <meta attribute="componentonly" inherit="true"/> + <meta attribute="implements">AnotherInterface</meta> + <meta attribute="allcomponent"/> + <meta attribute="globalmutated">monetaryamount level</meta> + <property name="X"> + <meta attribute="globalmutated">monetaryamount x level</meta> + </property> + </component> + + <set name="SortedEmployee" sort="NonExistingComparator"> + <meta attribute="globalmutated">sortedemployee level</meta> + <key column="attrb_id"/> + <many-to-many class="Employee" column="id"/> + </set> + + <bag name="AnotherSet"> + <key column="attrb2_id"/> + <composite-element class="Employee"> + <meta attribute="globalmutated">monetaryamount anotherSet composite level</meta> + <property name="Emp" type="string"> + <meta attribute="globalmutated">monetaryamount anotherSet composite property emp level</meta> + </property> + <many-to-one name="Empinone" class="Employee"> + <meta attribute="globalmutated">monetaryamount anotherSet composite property empinone level</meta> + </many-to-one> + </composite-element> + </bag> + + </class> + + <class name="Employee"> + <id name="Id"> + <generator class="assigned"/> + </id> + </class> +</hibernate-mapping> + Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-11 16:27:09 UTC (rev 4281) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-12 04:53:16 UTC (rev 4282) @@ -325,6 +325,8 @@ <Compile Include="HQL\Ast\WithClauseFixture.cs" /> <Compile Include="HQL\Ast\Zoo.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> + <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> + <Compile Include="MappingTest\Wicked.cs" /> <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\Person.cs" /> @@ -1766,6 +1768,7 @@ <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1391\Mappings.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\Animal.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-05-11 16:27:15
|
Revision: 4281 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4281&view=rev Author: tehlike Date: 2009-05-11 16:27:09 +0000 (Mon, 11 May 2009) Log Message: ----------- Ignored tests for NH-1391 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Animal.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Cat.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Dog.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Person.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAllTypes.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAnimals.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithCats.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithDogs.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithSivasKangals.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/SivasKangal.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Animal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Animal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Animal.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class Animal + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual Person Owner { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Cat.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Cat.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Cat.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class Cat:Animal + { + public virtual string EyeColor { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Dog.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Dog.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Dog.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class Dog:Animal + { + public virtual string Country { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + [TestFixture,Ignore] + public class Fixture:BugTestCase + { + protected override void OnSetUp() + { + using(var session=OpenSession()) + using(var tran=session.BeginTransaction()) + { + PersonWithAnimals personWithAnimals = new PersonWithAnimals {Name = "fabio"}; + PersonWithCats personWithCats = new PersonWithCats {Name = "dario"}; + PersonWithSivasKangals personWithSivasKangals = new PersonWithSivasKangals {Name = "tuna"}; + PersonWithDogs personWithDogs = new PersonWithDogs {Name = "davy"}; + + var animalForAnimals = new Animal {Name = "Pasha",Owner=personWithAnimals}; + var dogForAnimals = new Dog { Name = "Efe", Country = "Turkey", Owner = personWithAnimals }; + var catForAnimals = new Cat { Name = "Tekir", EyeColor = "green", Owner = personWithAnimals }; + var sivasKangalForAnimals = new SivasKangal { Name = "Karabas", Country = "Turkey", HouseAddress = "Atakoy", Owner = personWithAnimals }; + + personWithAnimals.AnimalsGeneric.Add(animalForAnimals); + personWithAnimals.AnimalsGeneric.Add(dogForAnimals); + personWithAnimals.AnimalsGeneric.Add(catForAnimals); + personWithAnimals.AnimalsGeneric.Add(sivasKangalForAnimals); + + var animalForCats = new Animal {Name = "Pasha2", Owner = personWithCats}; + var catForCats = new Cat { Name = "Tekir2", EyeColor = "green", Owner = personWithCats }; + var dogForCats = new Dog { Name = "Efe2", Country = "Turkey", Owner = personWithCats }; + personWithCats.AnimalsGeneric.Add(catForCats); + + var catForDogs = new Cat {Name = "Tekir3", EyeColor = "blue", Owner = personWithDogs}; + var dogForDogs = new Dog { Name = "Efe3", Country = "Turkey", Owner = personWithDogs }; + var sivasKangalForDogs = new SivasKangal { Name = "Karabas3", Country = "Turkey", HouseAddress = "Atakoy", Owner = personWithDogs }; + personWithDogs.AnimalsGeneric.Add(dogForDogs); + personWithDogs.AnimalsGeneric.Add(sivasKangalForDogs); + + var animalForSivasKangals = new Animal {Name = "Pasha4", Owner = personWithSivasKangals}; + var dogForSivasKangals = new Dog {Name = "Efe4", Country = "Turkey", Owner = personWithSivasKangals}; + var catForSivasKangals = new Cat {EyeColor = "red", Name = "Tekir4", Owner = personWithSivasKangals}; + var sivasKangalForSivasKangals = new SivasKangal { Name = "Karabas4", Country = "Turkey", HouseAddress = "Atakoy", Owner = personWithSivasKangals }; + personWithSivasKangals.AnimalsGeneric.Add(sivasKangalForSivasKangals); + + + session.Save(animalForCats); + session.Save(dogForCats); + + session.Save(catForDogs); + + session.Save(animalForSivasKangals); + session.Save(dogForSivasKangals); + session.Save(catForSivasKangals); + + session.Save(personWithAnimals); + session.Save(personWithCats); + session.Save(personWithDogs); + session.Save(personWithSivasKangals); + + + + tran.Commit(); + } + } + protected override void OnTearDown() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from Animal"); + session.Delete("from Person"); + tran.Commit(); + } + } + + + [Test] + public void Can_discriminate_subclass_on_list_with_lazy_loading_when_used_get() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + var personWithAnimals = session.Get<PersonWithAnimals>(1); + var personWithCats = session.Get<PersonWithCats>(2); + var personWithDogs = session.Get<PersonWithDogs>(3); + var personWithSivasKangals = session.Get<PersonWithSivasKangals>(4); + + Assert.That(personWithAnimals.AnimalsGeneric,Has.Count.EqualTo(4)); + Assert.That(personWithAnimals.AnimalsNonGeneric, Has.Count.EqualTo(4)); + + Assert.That(personWithCats.CatsGeneric, Has.Count.EqualTo(1)); + Assert.That(personWithCats.CatsNonGeneric, Has.Count.EqualTo(1)); + + Assert.That(personWithDogs.DogsGeneric, Has.Count.EqualTo(2)); + Assert.That(personWithDogs.DogsNonGeneric, Has.Count.EqualTo(2)); + + Assert.That(personWithSivasKangals.SivasKangalsGeneric, Has.Count.EqualTo(1)); + Assert.That(personWithSivasKangals.SivasKangalsNonGeneric, Has.Count.EqualTo(1)); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + [TestFixture,Ignore] + public class Fixture2:BugTestCase + { + protected override void OnSetUp() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + PersonWithAllTypes personWithAllTypes = new PersonWithAllTypes(); + Animal animal = new Animal { Name = "Pasha", Owner = personWithAllTypes }; + Dog dog = new Dog { Country = "Turkey", Name = "Kral", Owner = personWithAllTypes }; + SivasKangal sivasKangal = new SivasKangal + { + Name = "Karabas", + Country = "Turkey", + HouseAddress = "Address", + Owner = personWithAllTypes + }; + Cat cat = new Cat { Name = "Tekir", EyeColor = "Red", Owner = personWithAllTypes }; + personWithAllTypes.AnimalsGeneric.Add(animal); + personWithAllTypes.AnimalsGeneric.Add(cat); + personWithAllTypes.AnimalsGeneric.Add(dog); + personWithAllTypes.AnimalsGeneric.Add(sivasKangal); + session.Save(personWithAllTypes); + tran.Commit(); + } + } + protected override void OnTearDown() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from Animal"); + session.Delete("from Person"); + tran.Commit(); + } + } + + + [Test] + public void Can_discriminate_subclass_on_list_with_lazy_loading_when_used_and_person_had_multiple_list() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + var personWithAnimals = session.Get<PersonWithAllTypes>(1); + Assert.That(personWithAnimals.AnimalsNonGeneric, Has.Count.EqualTo(4)); + Assert.That(personWithAnimals.AnimalsGeneric, Has.Count.EqualTo(4)); + Assert.That(personWithAnimals.CatsNonGeneric, Has.Count.EqualTo(1)); + Assert.That(personWithAnimals.CatsGeneric,Has.Count.EqualTo(1)); + Assert.That(personWithAnimals.DogsNonGeneric, Has.Count.EqualTo(2)); + Assert.That(personWithAnimals.DogsGeneric,Has.Count.EqualTo(2)); + Assert.That(personWithAnimals.SivasKangalsNonGeneric, Has.Count.EqualTo(1)); + Assert.That(personWithAnimals.SivasKangalsGeneric, Has.Count.EqualTo(1)); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1391"> + + <class name="Animal" discriminator-value="0"> + <id name="Id" type="int"> + <generator class="native"/> + </id> + <discriminator column="AnimalType" type="int"/> + <property name="Name" type="string"/> + <many-to-one name="Owner" class="Person" column="OwnerId"/> + <subclass name="Cat" discriminator-value="1"/> + <subclass name="Dog" discriminator-value="2"> + <property name="Country"/> + <subclass name="SivasKangal" discriminator-value="3"> + <property name="HouseAddress"></property> + </subclass> + </subclass> + </class> + <class name="Person" discriminator-value="0"> + <id name="Id"> + <generator class="native"/> + </id> + + <discriminator column="PersonType" type="int"/> + <property name="Name"/> + <bag name="AnimalsNonGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="Animal"/> + </bag> + <bag name="AnimalsGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="Animal"/> + </bag> + <subclass name="PersonWithAnimals" discriminator-value="1"> + + </subclass> + <subclass name="PersonWithCats" discriminator-value="2"> + <bag name="CatsGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="Cat"/> + </bag> + <bag name="CatsNonGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="Cat"/> + </bag> + </subclass> + <subclass name="PersonWithDogs" discriminator-value="3"> + <bag name="DogsGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="Dog"/> + </bag> + <bag name="DogsNonGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="Dog"/> + </bag> + </subclass> + <subclass name="PersonWithSivasKangals" discriminator-value="4"> + <bag name="SivasKangalsGeneric" lazy="true" inverse="true" cascade="save-update"> + <key column="OwnerId" /> + <one-to-many class="SivasKangal"/> + </bag> + <bag name="SivasKangalsNonGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="SivasKangal"/> + </bag> + </subclass> + <subclass name="PersonWithAllTypes" discriminator-value="5"> + <bag name="DogsGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="Dog"/> + </bag> + <bag name="DogsNonGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="Dog"/> + </bag> + <bag name="CatsGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="Cat"/> + </bag> + <bag name="CatsNonGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="Cat"/> + </bag> + <bag name="SivasKangalsGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="SivasKangal"/> + </bag> + <bag name="SivasKangalsNonGeneric" lazy="true" inverse="true"> + <key column="OwnerId" /> + <one-to-many class="SivasKangal"/> + </bag> + </subclass> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Person.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,20 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class Person + { + public Person() + { + this.AnimalsGeneric = new List<Animal>(); + this.AnimalsNonGeneric = new ArrayList(); + } + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual IList<Animal> AnimalsGeneric { get; set; } + public virtual IList AnimalsNonGeneric { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAllTypes.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAllTypes.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAllTypes.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class PersonWithAllTypes:Person + { + public virtual IList<Dog> DogsNonGeneric { get; set; } + public virtual IList<SivasKangal> SivasKangalsNonGeneric { get; set; } + public virtual IList<Cat> CatsNonGeneric { get; set; } + + + public virtual IList<Dog> DogsGeneric { get; set; } + public virtual IList<SivasKangal> SivasKangalsGeneric { get; set; } + public virtual IList<Cat> CatsGeneric { get; set; } + } + +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAnimals.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAnimals.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAnimals.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,16 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class PersonWithAnimals:Person + { + public PersonWithAnimals() + { + + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithCats.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithCats.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithCats.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,18 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class PersonWithCats : Person + { + public PersonWithCats() + { + this.CatsGeneric = new List<Cat>(); + this.CatsNonGeneric = new ArrayList(); + } + public virtual IList CatsNonGeneric { get; set; } + public virtual IList<Cat> CatsGeneric { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithDogs.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithDogs.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithDogs.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,18 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class PersonWithDogs : Person + { + public PersonWithDogs() + { + this.DogsGeneric = new List<Dog>(); + this.DogsNonGeneric = new ArrayList(); + } + public virtual IList DogsNonGeneric { get; set; } + public virtual IList<Dog> DogsGeneric { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithSivasKangals.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithSivasKangals.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithSivasKangals.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,18 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class PersonWithSivasKangals:Person + { + public PersonWithSivasKangals() + { + this.SivasKangalsGeneric = new List<SivasKangal>(); + this.SivasKangalsNonGeneric = new ArrayList(); + } + public virtual IList SivasKangalsNonGeneric { get; set; } + public virtual IList<SivasKangal> SivasKangalsGeneric { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/SivasKangal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/SivasKangal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/SivasKangal.cs 2009-05-11 16:27:09 UTC (rev 4281) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1391 +{ + public class SivasKangal:Dog + { + public virtual string HouseAddress { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-11 14:51:46 UTC (rev 4280) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-11 16:27:09 UTC (rev 4281) @@ -332,6 +332,20 @@ <Compile Include="NHSpecificTest\Futures\FutureFixture.cs" /> <Compile Include="NHSpecificTest\Logs\LogsFixture.cs" /> <Compile Include="NHSpecificTest\Logs\Person.cs" /> + <Compile Include="NHSpecificTest\NH1391\Animal.cs" /> + <Compile Include="NHSpecificTest\NH1391\Cat.cs" /> + <Compile Include="NHSpecificTest\NH1391\Dog.cs" /> + <Compile Include="NHSpecificTest\NH1391\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1391\Fixture2.cs" /> + <Compile Include="NHSpecificTest\NH1391\Person.cs" /> + <Compile Include="NHSpecificTest\NH1391\PersonWithAllTypes.cs" /> + <Compile Include="NHSpecificTest\NH1391\PersonWithAnimals.cs" /> + <Compile Include="NHSpecificTest\NH1391\PersonWithCats.cs" /> + <Compile Include="NHSpecificTest\NH1391\PersonWithDogs.cs" /> + <Compile Include="NHSpecificTest\NH1391\PersonWithSivasKangals.cs" /> + <Compile Include="NHSpecificTest\NH1391\SivasKangal.cs" /> + <Compile Include="NHSpecificTest\NH1393\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1393\Person.cs" /> <Compile Include="NHSpecificTest\NH1635\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1635\ForumMessage.cs" /> <Compile Include="NHSpecificTest\NH1635\ForumThread.cs" /> @@ -611,8 +625,6 @@ <Compile Include="NHSpecificTest\NH1355\Category.cs" /> <Compile Include="NHSpecificTest\NH1355\CustomVersionType.cs" /> <Compile Include="NHSpecificTest\NH1355\UserTypeTimestamp.cs" /> - <Compile Include="NHSpecificTest\NH1393\Fixture.cs" /> - <Compile Include="NHSpecificTest\NH1393\Person.cs" /> <Compile Include="NHSpecificTest\NH1394\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1394\Person.cs" /> <Compile Include="NHSpecificTest\NH1399\Fixture.cs" /> @@ -1754,6 +1766,8 @@ <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1391\Mappings.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\Animal.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\BooleanLiteralEntity.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\EntityWithCrazyCompositeKey.hbm.xml" /> @@ -1906,7 +1920,6 @@ <EmbeddedResource Include="NHSpecificTest\NH1413\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1304\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1408\Mappings.hbm.xml" /> - <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1394\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1405\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1403\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-11 15:01:15
|
Revision: 4278 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4278&view=rev Author: fabiomaulo Date: 2009-05-11 13:43:54 +0000 (Mon, 11 May 2009) Log Message: ----------- Fix NH-1770 (hard to test because, without another assembly, because it involve app.config; threre is an existing test about <session-factory> "optionability") Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-05-11 06:42:20 UTC (rev 4277) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-05-11 13:43:54 UTC (rev 4278) @@ -215,9 +215,12 @@ GlobalProperties[PropertyBytecodeProvider] = CfgXmlHelper.ByteCodeProviderToString(nhConfig.ByteCodeProviderType); GlobalProperties[PropertyUseReflectionOptimizer] = nhConfig.UseReflectionOptimizer.ToString(); - foreach (KeyValuePair<string, string> kvp in nhConfig.SessionFactory.Properties) + if (nhConfig.SessionFactory != null) { - GlobalProperties[kvp.Key] = kvp.Value; + foreach (KeyValuePair<string, string> kvp in nhConfig.SessionFactory.Properties) + { + GlobalProperties[kvp.Key] = kvp.Value; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-11 14:51:51
|
Revision: 4280 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4280&view=rev Author: fabiomaulo Date: 2009-05-11 14:51:46 +0000 (Mon, 11 May 2009) Log Message: ----------- New parser as default. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate.Test/App.config Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-05-11 13:59:15 UTC (rev 4279) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-05-11 14:51:46 UTC (rev 4280) @@ -326,7 +326,7 @@ private static IQueryTranslatorFactory CreateQueryTranslatorFactory(IDictionary<string, string> properties) { string className = PropertiesHelper.GetString( - Environment.QueryTranslator, properties, typeof(Hql.Classic.ClassicQueryTranslatorFactory).FullName); + Environment.QueryTranslator, properties, typeof(Hql.Ast.ANTLR.ASTQueryTranslatorFactory).FullName); log.Info("Query translator: " + className); try { Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-11 13:59:15 UTC (rev 4279) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-11 14:51:46 UTC (rev 4280) @@ -60,8 +60,6 @@ <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property> - <property name="query.factory_class">NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory, NHibernate</property> - <property name="show_sql">false</property> <property name="use_outer_join">true</property> <property name="command_timeout">444</property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-11 13:59:25
|
Revision: 4279 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4279&view=rev Author: ayenderahien Date: 2009-05-11 13:59:15 +0000 (Mon, 11 May 2009) Log Message: ----------- Will now log a warning when getting exception from the database Logging of messages in the SqlClientBatchingBatcher now follow a more consistent approach per logging based on which logger is used Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-11 13:43:54 UTC (rev 4278) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-11 13:59:15 UTC (rev 4279) @@ -199,6 +199,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; + log.Warn("Could not execute command: " + cmd.CommandText, e); throw; } } @@ -216,6 +217,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; + log.Warn("Could not exeucte query: " + cmd.CommandText, e); throw; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-11 13:43:54 UTC (rev 4278) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-11 13:59:15 UTC (rev 4279) @@ -19,10 +19,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - if(log.IsDebugEnabled) - { - currentBatchCommandsLog = new StringBuilder(); - } + currentBatchCommandsLog = new StringBuilder(); } public override int BatchSize @@ -35,22 +32,15 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled) + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else + else if (log.IsDebugEnabled) { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + log.Debug("Adding to batch:" + lineWithParameters); } currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); if (currentBatch.CountOfCommands >= batchSize) @@ -64,14 +54,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled) - { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - } + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-11 06:42:34
|
Revision: 4277 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4277&view=rev Author: fabiomaulo Date: 2009-05-11 06:42:20 +0000 (Mon, 11 May 2009) Log Message: ----------- Changed the HQL only to be really similar to the Criteria (using explicit join in both) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2009-05-11 06:39:49 UTC (rev 4276) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2009-05-11 06:42:20 UTC (rev 4277) @@ -48,7 +48,7 @@ fltr.SetParameter("activeFlag", 1); // with HQL, Category.IsActive=true filter applied, result count=2 - IQuery hqlQuery = s.CreateQuery("from Customer c where c.Category.Name = ?"); + IQuery hqlQuery = s.CreateQuery("from Customer c join c.Category cat where cat.Name = ?"); hqlQuery.SetParameter(0, "User"); // note using positional parameters because of NH-1490 IList<Customer> hqlResult = hqlQuery.List<Customer>(); Console.WriteLine(hqlResult.Count); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-11 06:39:59
|
Revision: 4276 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4276&view=rev Author: fabiomaulo Date: 2009-05-11 06:39:49 +0000 (Mon, 11 May 2009) Log Message: ----------- Fixed NH-1179 Possible breaking change: now filters are working, as expected, even for many-to-one associations Modified Paths: -------------- trunk/nhibernate/releasenotes.txt trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs trunk/nhibernate/src/NHibernate/SqlCommand/QueryJoinFragment.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/releasenotes.txt 2009-05-11 06:39:49 UTC (rev 4276) @@ -24,6 +24,7 @@ ##### Breaking Changes ##### * see NH-1633 if you are using SQL native queries * CriteriaUtil is gone. NHibernate.Transform.Transformers now returns predefined IResultTransformer. + * Now filters are working even with many-to-one association for Criteria and HQL (NH-1293, NH-1179) Build 2.1.0.Alpha2 (rev4167) ======================== Modified: trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2009-05-11 06:39:49 UTC (rev 4276) @@ -166,31 +166,33 @@ string on = join.AssociationType.GetOnCondition(join.Alias, factory, enabledFilters); string condition; if (last != null && - IsManyToManyRoot(last) && - ((IQueryableCollection) last).ElementType == join.AssociationType) + IsManyToManyRoot(last) && + ((IQueryableCollection)last).ElementType == join.AssociationType) { // the current join represents the join between a many-to-many association table // and its "target" table. Here we need to apply any additional filters // defined specifically on the many-to-many - string manyToManyFilter = ((IQueryableCollection) last) + string manyToManyFilter = ((IQueryableCollection)last) .GetManyToManyFilterFragment(join.Alias, enabledFilters); condition = "".Equals(manyToManyFilter) - ? on - : "".Equals(on) - ? manyToManyFilter - : on + " and " + manyToManyFilter; + ? on + : "".Equals(on) + ? manyToManyFilter + : on + " and " + manyToManyFilter; } else { - condition = on; + // NH Different behavior : NH1179 and NH1293 + // Apply filters in Many-To-One association + if (string.IsNullOrEmpty(on) && enabledFilters.Count > 0) + { + condition = join.Joinable.FilterFragment(join.Alias, enabledFilters); + } + else + { + condition = on; + } } - //Start NH1179 ************ - //if (string.IsNullOrEmpty(condition)) - //{ - // string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters); - // joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition); - //} - //End NH1179 ************ if (withClauseFragment != null) { Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-05-11 06:39:49 UTC (rev 4276) @@ -564,10 +564,20 @@ foreach (OuterJoinableAssociation oj in associations) { if (last != null && last.IsManyToManyWith(oj)) - oj.AddManyToManyJoin(outerjoin, (IQueryableCollection)last.Joinable); + { + oj.AddManyToManyJoin(outerjoin, (IQueryableCollection) last.Joinable); + } else + { oj.AddJoins(outerjoin); - + // NH Different behavior : NH1179 and NH1293 + // Apply filters in Many-To-One association + if (enabledFilters.Count > 0) + { + var manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFilters); + outerjoin.AddCondition(manyToOneFilterFragment); + } + } last = oj; } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs 2009-05-11 06:39:49 UTC (rev 4276) @@ -9,7 +9,7 @@ public class ANSIJoinFragment : JoinFragment { private SqlStringBuilder buffer = new SqlStringBuilder(); - private SqlStringBuilder conditions = new SqlStringBuilder(); + private readonly SqlStringBuilder conditions = new SqlStringBuilder(); public override void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType) { @@ -86,12 +86,12 @@ public override bool AddCondition(string condition) { - throw new NotSupportedException(); + return AddCondition(conditions, condition); } public override bool AddCondition(SqlString condition) { - throw new NotSupportedException(); + return AddCondition(conditions, condition); } public override void AddFromFragmentString(SqlString fromFragmentString) Modified: trunk/nhibernate/src/NHibernate/SqlCommand/QueryJoinFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/QueryJoinFragment.cs 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/src/NHibernate/SqlCommand/QueryJoinFragment.cs 2009-05-11 06:39:49 UTC (rev 4276) @@ -85,9 +85,10 @@ public override bool AddCondition(string condition) { //TODO: this seems hackish + var trimCondition = condition.Trim(); if ( - afterFrom.ToSqlString().ToString().IndexOf(condition.Trim()) < 0 && - afterWhere.ToSqlString().ToString().IndexOf(condition.Trim()) < 0) + afterFrom.ToSqlString().ToString().IndexOf(trimCondition) < 0 && + afterWhere.ToSqlString().ToString().IndexOf(trimCondition) < 0) { if (!condition.StartsWith(" and ")) { @@ -104,9 +105,10 @@ public override bool AddCondition(SqlString condition) { //TODO: this seems hackish + var trimCondition = condition.Trim().ToString(); if ( - afterFrom.ToString().IndexOf(condition.Trim().ToString()) < 0 && - afterWhere.ToString().IndexOf(condition.Trim().ToString()) < 0) + afterFrom.ToString().IndexOf(trimCondition) < 0 && + afterWhere.ToString().IndexOf(trimCondition) < 0) { if (!condition.StartsWithCaseInsensitive(" and ")) { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2009-05-10 14:55:50 UTC (rev 4275) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2009-05-11 06:39:49 UTC (rev 4276) @@ -11,11 +11,9 @@ get { return "NH1179"; } } - [Test, Ignore("Not supported.")] + [Test] public void ApplyFilterExplicitJoin() { - // Note: if we fix this we must fix it for Criteria too (NH-1293) - RelatedClass rc1 = new RelatedClass(1); RelatedClass rc2 = new RelatedClass(2); RelatedClass rc11 = new RelatedClass(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-10 14:55:58
|
Revision: 4275 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4275&view=rev Author: fabiomaulo Date: 2009-05-10 14:55:50 +0000 (Sun, 10 May 2009) Log Message: ----------- New parser as default for ours tests Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-10 14:30:22 UTC (rev 4274) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-10 14:55:50 UTC (rev 4275) @@ -60,6 +60,7 @@ <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property> + <property name="query.factory_class">NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory, NHibernate</property> <property name="show_sql">false</property> <property name="use_outer_join">true</property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-10 14:30:30
|
Revision: 4274 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4274&view=rev Author: fabiomaulo Date: 2009-05-10 14:30:22 +0000 (Sun, 10 May 2009) Log Message: ----------- Fixed bug in AST parser (NHibernate.Test.Legacy.Query full supported) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs trunk/nhibernate/src/NHibernate.Test/App.config Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-10 14:30:22 UTC (rev 4274) @@ -818,28 +818,27 @@ protected IASTNode LookupProperty(IASTNode dot, bool root, bool inSelect) { - DotNode dotNode = ( DotNode ) dot; + DotNode dotNode = (DotNode) dot; FromReferenceNode lhs = dotNode.GetLhs(); IASTNode rhs = lhs.NextSibling; - switch ( rhs.Type ) { + switch (rhs.Type) + { case ELEMENTS: case INDICES: - if ( log.IsDebugEnabled ) + if (log.IsDebugEnabled) { - log.Debug( "lookupProperty() " + dotNode.Path + " => " + rhs.Text + "(" + lhs.Path + ")" ); + log.Debug("lookupProperty() " + dotNode.Path + " => " + rhs.Text + "(" + lhs.Path + ")"); } - CollectionFunction f = ( CollectionFunction ) rhs; + CollectionFunction f = (CollectionFunction) rhs; // Re-arrange the tree so that the collection function is the root and the lhs is the path. - f.ClearChildren(); - f.AddChild(lhs); + f.SetFirstChild(lhs); + lhs.NextSibling = null; + dotNode.SetFirstChild(f); - dotNode.ClearChildren(); - dotNode.AddChild(f); - - Resolve( lhs ); // Don't forget to resolve the argument! - f.Resolve( inSelect ); // Resolve the collection function now. + Resolve(lhs); // Don't forget to resolve the argument! + f.Resolve(inSelect); // Resolve the collection function now. return f; default: // Resolve everything up to this dot, but don't resolve the placeholders yet. @@ -899,8 +898,7 @@ syntheticAlias.FromElement = fromElement; syntheticAlias.IsResolved = true; - dot.ClearChildren(); - dot.AddChild(syntheticAlias); + dot.SetFirstChild(syntheticAlias); dot.AddChild(property); return dot; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-10 14:30:22 UTC (rev 4274) @@ -143,11 +143,11 @@ public override void ResolveFirstChild() { - FromReferenceNode lhs = (FromReferenceNode)GetChild(0); - SqlNode property = (SqlNode)GetChild(1); + var lhs = (FromReferenceNode)GetFirstChild(); + var property = (SqlNode) GetChild(1); // Set the attributes of the property reference expression. - String propName = property.Text; + string propName = property.Text; _propertyName = propName; // If the uresolved property path isn't set yet, just use the property name. @@ -222,15 +222,16 @@ DereferenceEntity( ( EntityType ) propertyType, implicitJoin, classAlias, generateJoin, parent ); InitText(); } - else if ( propertyType.IsCollectionType ) + else if (propertyType.IsCollectionType) { // The property is a collection... CheckLhsIsNotCollection(); - DereferenceCollection( ( CollectionType ) propertyType, implicitJoin, false, classAlias, parent ); + DereferenceCollection((CollectionType)propertyType, implicitJoin, false, classAlias, parent); } - else { + else + { // Otherwise, this is a primitive type. - if ( ! CollectionProperties.IsAnyCollectionProperty( _propertyName ) ) + if (!CollectionProperties.IsAnyCollectionProperty(_propertyName)) { CheckLhsIsNotCollection(); } @@ -531,9 +532,9 @@ private void SetImpliedJoin(FromElement elem) { _impliedJoin = elem; - if (GetChild(0).Type == HqlSqlWalker.DOT) + if (GetFirstChild().Type == HqlSqlWalker.DOT) { - DotNode dotLhs = (DotNode)GetChild(0); + DotNode dotLhs = (DotNode)GetFirstChild(); if (dotLhs.GetImpliedJoin() != null) { _impliedJoin = dotLhs.GetImpliedJoin(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-10 14:30:22 UTC (rev 4274) @@ -303,14 +303,16 @@ { 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 (numberOfTables > 1 && _implied && !elem.UseFromFragment) + // NH Different behavior: numberOfTables was removed because an + // implicit join is an implicit join even if it not come from a + // multi-table entity + if (_implied && !elem.UseFromFragment) { if (log.IsDebugEnabled) { - log.Debug("createEntityJoin() : Implied multi-table entity join"); + log.Debug("createEntityJoin() : Implied entity join"); } elem.UseFromFragment = true; } @@ -329,9 +331,7 @@ // 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) + if (elem.FromClause != elem.Origin.FromClause || DotNode.UseThetaStyleImplicitJoins) { // the "root from-element" in correlated subqueries do need this piece elem.Type = HqlSqlWalker.FROM_FRAGMENT; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-10 14:30:22 UTC (rev 4274) @@ -76,7 +76,7 @@ public void RecursiveResolve(int level, bool impliedAtRoot, string classAlias, IASTNode parent) { - IASTNode lhs = this.GetChild(0); + IASTNode lhs = GetFirstChild(); int nextLevel = level + 1; if ( lhs != null ) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-10 14:30:22 UTC (rev 4274) @@ -126,7 +126,7 @@ else if (parent != null && parent.Type == HqlSqlWalker.DOT) { DotNode dot = (DotNode)parent; - if (parent.GetChild(0) == this) + if (parent.GetFirstChild() == this) { if (ResolveAsNakedComponentPropertyRefLHS(dot)) { Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-09 16:07:27 UTC (rev 4273) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-05-10 14:30:22 UTC (rev 4274) @@ -118,7 +118,7 @@ <appender-ref ref="console" /> </root> - <logger name="NHibernate.Bytecode.CodeDom"> + <logger name="NHibernate.Hql.Ast.ANTLR"> <priority value="OFF" /> </logger> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-05-09 16:07:37
|
Revision: 4273 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4273&view=rev Author: tehlike Date: 2009-05-09 16:07:27 +0000 (Sat, 09 May 2009) Log Message: ----------- Adding Spring and Common.Logging dlls. Added Paths: ----------- trunk/nhibernate/lib/net/2.0/Common.Logging.dll trunk/nhibernate/lib/net/2.0/Spring.Aop.dll trunk/nhibernate/lib/net/2.0/Spring.Aop.xml trunk/nhibernate/lib/net/2.0/Spring.Core.dll trunk/nhibernate/lib/net/2.0/Spring.Core.xml Added: trunk/nhibernate/lib/net/2.0/Common.Logging.dll =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/lib/net/2.0/Common.Logging.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/nhibernate/lib/net/2.0/Spring.Aop.dll =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/lib/net/2.0/Spring.Aop.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/nhibernate/lib/net/2.0/Spring.Aop.xml =================================================================== --- trunk/nhibernate/lib/net/2.0/Spring.Aop.xml (rev 0) +++ trunk/nhibernate/lib/net/2.0/Spring.Aop.xml 2009-05-09 16:07:27 UTC (rev 4273) @@ -0,0 +1,11277 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>Spring.Aop</name> + </assembly> + <members> + <member name="T:Spring.Aop.Config.AopNamespaceParser"> + <summary> + Namespace parser for the aop namespace. + </summary> + <remarks> + Using the <code>advisor</code> tag you can configure an <see cref="T:Spring.Aop.IAdvisor"/> and have it + applied to all the relevant objects in your application context automatically. The + <code>advisor</code> tag supports only referenced <see cref="T:Spring.Aop.IPointcut"/>s. + </remarks> + <author>Rob harrop</author> + <author>Adrian Colyer</author> + <author>Rod Johnson</author> + <author>Mark Pollack (.NET)</author> + </member> + <member name="M:Spring.Aop.Config.AopNamespaceParser.Init"> + <summary> + Register the <see cref="T:Spring.Objects.Factory.Xml.IObjectDefinitionParser"/> for the '<code>config</code>' tag. + </summary> + </member> + <member name="T:Spring.Aop.Config.AopNamespaceUtils"> + <summary> + Utility class for handling registration of auto-proxy creators used internally by the + <code>aop</code> namespace tags. + </summary> + <author>Rob Harrop</author> + <author>Juergen Hoeller</author> + <author>Mark Pollack (.NET)</author> + </member> + <member name="F:Spring.Aop.Config.AopNamespaceUtils.AUTO_PROXY_CREATOR_OBJECT_NAME"> + <summary> + The object name of the internally managed auto-proxy creator. + </summary> + </member> + <member name="M:Spring.Aop.Config.AopNamespaceUtils.RegisterAutoProxyCreatorIfNecessary(Spring.Objects.Factory.Xml.ParserContext,System.Xml.XmlElement)"> + <summary> + Registers the auto proxy creator if necessary. + </summary> + <param name="parserContext">The parser context.</param> + <param name="sourceElement">The source element.</param> + </member> + <member name="M:Spring.Aop.Config.AopNamespaceUtils.RegisterApcAsRequired(System.Type,Spring.Objects.Factory.Xml.ParserContext)"> + <summary> + Registries the or escalate apc as required. + </summary> + <param name="type">The type.</param> + <param name="parserContext">The parser context.</param> + </member> + <member name="M:Spring.Aop.Config.AopNamespaceUtils.ForceAutoProxyCreatorToUseDecoratorProxy(Spring.Objects.Factory.Support.IObjectDefinitionRegistry)"> + <summary> + Forces the auto proxy creator to use decorator proxy. + </summary> + <param name="registry">The registry.</param> + </member> + <member name="T:Spring.Aop.Config.ConfigObjectDefinitionParser"> + <summary> + The <see cref="T:Spring.Objects.Factory.Xml.IObjectDefinitionParser"/> for the <code><aop:config></code> tag. + </summary> + <author>Mark Pollack (.NET)</author> + </member> + <member name="F:Spring.Aop.Config.ConfigObjectDefinitionParser.PROXY_TARGET_TYPE"> + <summary> + The '<code>proxy-target-type</code>' attribute + </summary> + </member> + <member name="M:Spring.Aop.Config.ConfigObjectDefinitionParser.ParseElement(System.Xml.XmlElement,Spring.Objects.Factory.Xml.ParserContext)"> + <summary> + Parse the specified XmlElement and register the resulting + ObjectDefinitions with the <see cref="P:Spring.Objects.Factory.Xml.ParserContext.Registry"/> IObjectDefinitionRegistry + embedded in the supplied <see cref="T:Spring.Objects.Factory.Xml.ParserContext"/> + </summary> + <param name="element">The element to be parsed.</param> + <param name="parserContext">The object encapsulating the current state of the parsing process. + Provides access to a IObjectDefinitionRegistry</param> + <returns>The primary object definition.</returns> + <remarks> + <p> + This method is never invoked if the parser is namespace aware + and was called to process the root node. + </p> + </remarks> + </member> + <member name="M:Spring.Aop.Config.ConfigObjectDefinitionParser.ParseAdvisor(System.Xml.XmlElement,Spring.Objects.Factory.Xml.ParserContext)"> + <summary> + Parses the supplied advisor element and registers the resulting <see cref="T:Spring.Aop.IAdvisor"/> + </summary> + <param name="advisorElement">The advisor element.</param> + <param name="parserContext">The parser context.</param> + </member> + <member name="T:Spring.Aop.Framework.Adapter.AdvisorAdapterRegistrationManager"> + <summary> + <see cref="T:Spring.Objects.Factory.Config.IObjectPostProcessor"/> implementation + that registers instances of any non-default + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> instances with the + <see cref="T:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry"/> + singleton. + </summary> + <remarks> + <p> + The only requirement for it to work is that it needs to be defined + in an application context along with any arbitrary "non-native" Spring.NET + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> instances that need + to be recognized by Spring.NET's AOP framework. + </p> + </remarks> + <author>Dmitriy Kopylenko</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AdvisorAdapterRegistrationManager.PostProcessBeforeInitialization(System.Object,System.String)"> + <summary> + Apply this <see cref="T:Spring.Objects.Factory.Config.IObjectPostProcessor"/> + to the given new object instance <i>before</i> any object initialization callbacks. + </summary> + <remarks> + <p> + Does nothing, simply returns the supplied <paramref name="instance"/> as is. + </p> + </remarks> + <param name="instance"> + The new object instance. + </param> + <param name="name"> + The name of the object. + </param> + <returns> + The object instance to use, either the original or a wrapped one. + </returns> + <exception cref="T:Spring.Objects.ObjectsException"> + In case of errors. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AdvisorAdapterRegistrationManager.PostProcessAfterInitialization(System.Object,System.String)"> + <summary> + Apply this <see cref="T:Spring.Objects.Factory.Config.IObjectPostProcessor"/> to the + given new object instance <i>after</i> any object initialization callbacks. + </summary> + <remarks> + <p> + Registers the supplied <paramref name="instance"/> with the + <see cref="T:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry"/> + singleton if it is an <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> + instance. + </p> + </remarks> + <param name="instance"> + The new object instance. + </param> + <param name="objectName"> + The name of the object. + </param> + <returns> + The object instance to use, either the original or a wrapped one. + </returns> + <exception cref="T:Spring.Objects.ObjectsException"> + In case of errors. + </exception> + </member> + <member name="T:Spring.Aop.Framework.Adapter.AfterReturningAdviceAdapter"> + <summary> + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> implementation + to enable <see cref="T:Spring.Aop.IAfterReturningAdvice"/> to be used in the + Spring.NET AOP framework. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"> + <summary> + Permits the handling of new advisors and advice types as extensions to + the Spring AOP framework. + </summary> + <remarks> + <p> + Implementors can create AOP Alliance + <see cref="T:AopAlliance.Intercept.IInterceptor"/>s from custom advice + types, enabling these advice types to be used in the Spring.NET AOP + framework, which uses interception under the covers. + </p> + <p> + There is no need for most Spring.NET users to implement this interface; + do so only if you need to introduce more + <see cref="T:Spring.Aop.IAdvisor"/> or <see cref="T:AopAlliance.Aop.IAdvice"/> + types to Spring.NET. + </p> + </remarks> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.IAdvisorAdapter.SupportsAdvice(AopAlliance.Aop.IAdvice)"> + <summary> + Does this adapter understand the supplied <paramref name="advice"/>? + </summary> + <remarks> + <p> + Is it valid to invoke the + <see cref="M:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry.Wrap(System.Object)"/> + method with the given advice as an argument? + </p> + </remarks> + <param name="advice"> + <see cref="T:AopAlliance.Aop.IAdvice"/> such as + <see cref="T:Spring.Aop.IBeforeAdvice"/>. + </param> + <returns><see langword="true"/> if this adapter understands the + supplied <paramref name="advice"/>. + </returns> + </member> + <member name="M:Spring.Aop.Framework.Adapter.IAdvisorAdapter.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Return an AOP Alliance + <see cref="T:AopAlliance.Intercept.IInterceptor"/> exposing the + behaviour of the given advice to an interception-based AOP + framework. + </summary> + <remarks> + <p> + Don't worry about any <see cref="T:Spring.Aop.IPointcut"/> + contained in the supplied <see cref="T:Spring.Aop.IAdvisor"/>; + the AOP framework will take care of checking the pointcut. + </p> + </remarks> + <param name="advisor"> + The advice. The + <see cref="M:Spring.Aop.Framework.Adapter.IAdvisorAdapter.SupportsAdvice(AopAlliance.Aop.IAdvice)"/> + method must have previously returned <see langword="true"/> on the + supplied <paramref name="advisor"/>. + </param> + <returns> + An AOP Alliance + <see cref="T:AopAlliance.Intercept.IInterceptor"/> exposing the + behaviour of the given advice to an interception-based AOP + framework. + </returns> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AfterReturningAdviceAdapter.SupportsAdvice(AopAlliance.Aop.IAdvice)"> + <summary> + Returns <see langword="true"/> if the supplied + <paramref name="advice"/> is an instance of the + <see cref="T:Spring.Aop.IAfterReturningAdvice"/> interface. + </summary> + <param name="advice">The advice to check.</param> + <returns> + <see langword="true"/> if the supplied <paramref name="advice"/> is + an instance of the <see cref="T:Spring.Aop.IAfterReturningAdvice"/> interface; + <see langword="false"/> if not or if the supplied + <paramref name="advice"/> is <cref lang="null"/>. + </returns> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AfterReturningAdviceAdapter.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Wraps the supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> within a + <see cref="T:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor"/> + instance. + </summary> + <param name="advisor"> + The advisor exposing the <see cref="T:AopAlliance.Aop.IAdvice"/> that + is to be wrapped. + </param> + <returns> + The supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> wrapped within a + <see cref="T:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor"/> + instance. + </returns> + </member> + <member name="T:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor"> + <summary> + Interceptor to wrap an <see cref="T:Spring.Aop.IAfterReturningAdvice"/> + instance. + </summary> + <remarks> + <p> + A more efficient alternative solution in cases where there is no + interception advice and therefore no need to create an + <see cref="T:AopAlliance.Intercept.IMethodInvocation"/> object may be + offered in future. + </p> + <p> + Used internally by the AOP framework: application developers should not need + to use this class directly. + </p> + </remarks> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="T:AopAlliance.Intercept.IMethodInterceptor"> + <summary> + Intercepts calls on an interface on its way to the target. + </summary> + <remarks> + <p> + Such interceptions are nested "on top" of the target. + </p> + </remarks> + </member> + <member name="T:AopAlliance.Intercept.IInterceptor"> + <summary> + Represents a generic interceptor. + </summary> + <remarks> + <p> + A generic interceptor can intercept runtime events that occur within a + base program. Those events are materialized by (reified in) joinpoints. + Runtime joinpoints can be invocations, field access, exceptions, etc. + </p> + <p> + This interface is not used directly. Use the various derived interfaces + to intercept specific events. + </p> + </remarks> + <seealso cref="T:AopAlliance.Intercept.IJoinpoint"/> + </member> + <member name="T:AopAlliance.Aop.IAdvice"> + <summary> + Tag interface for advice. + </summary> + <remarks> + <p> + Implementations can be any type of advice, such as interceptors. + </p> + </remarks> + </member> + <member name="M:AopAlliance.Intercept.IMethodInterceptor.Invoke(AopAlliance.Intercept.IMethodInvocation)"> + <summary> + Implement this method to perform extra treatments before and after + the call to the supplied <paramref name="invocation"/>. + </summary> + <remarks> + <p> + Polite implementations would certainly like to invoke + <see cref="M:AopAlliance.Intercept.IJoinpoint.Proceed"/>. + </p> + </remarks> + <param name="invocation"> + The method invocation that is being intercepted. + </param> + <returns> + The result of the call to the + <see cref="M:AopAlliance.Intercept.IJoinpoint.Proceed"/> method of + the supplied <paramref name="invocation"/>; this return value may + well have been intercepted by the interceptor. + </returns> + <exception cref="T:System.Exception"> + If any of the interceptors in the chain or the target object itself + throws an exception. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor.#ctor(Spring.Aop.IAfterReturningAdvice)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor"/> + class. + </summary> + <param name="advice"> + The advice to be applied after a target method successfully + returns. + </param> + <exception cref="T:System.ArgumentNullException"> + If the supplied <paramref name="advice"/> is <see langword="null"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor.Invoke(AopAlliance.Intercept.IMethodInvocation)"> + <summary> + Executes interceptor after the target method successfully returns. + </summary> + <param name="invocation"> + The method invocation that is being intercepted. + </param> + <returns> + The result of the call to the + <see cref="M:AopAlliance.Intercept.IJoinpoint.Proceed"/> method of + the supplied <paramref name="invocation"/>; this return value may + well have been intercepted by the interceptor. + </returns> + <exception cref="T:System.Exception"> + If any of the interceptors in the chain or the target object itself + throws an exception. + </exception> + </member> + <member name="T:Spring.Aop.Framework.Adapter.BeforeAdviceAdapter"> + <summary> + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> implementation + to enable <see cref="T:Spring.Aop.IMethodBeforeAdvice"/> to be used in the + Spring.NET AOP framework. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.BeforeAdviceAdapter.SupportsAdvice(AopAlliance.Aop.IAdvice)"> + <summary> + Returns <see langword="true"/> if the supplied + <paramref name="advice"/> is an instance of the + <see cref="T:Spring.Aop.IMethodBeforeAdvice"/> interface. + </summary> + <param name="advice">The advice to check.</param> + <returns> + <see langword="true"/> if the supplied <paramref name="advice"/> is + an instance of the <see cref="T:Spring.Aop.IMethodBeforeAdvice"/> interface; + <see langword="false"/> if not or if the supplied + <paramref name="advice"/> is <cref lang="null"/>. + </returns> + </member> + <member name="M:Spring.Aop.Framework.Adapter.BeforeAdviceAdapter.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Wraps the supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> within a + <see cref="T:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor"/> + instance. + </summary> + <param name="advisor"> + The advisor exposing the <see cref="T:AopAlliance.Aop.IAdvice"/> that + is to be wrapped. + </param> + <returns> + The supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> wrapped within a + <see cref="T:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor"/> + instance. + </returns> + </member> + <member name="T:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry"> + <summary> + Default implementation of the + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry"/> + interface. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="T:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry"> + <summary> + A registry of + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> instances. + </summary> + <remarks> + <p> + Implementations <b>must</b> also automatically register adapters for + <see cref="T:AopAlliance.Intercept.IInterceptor"/> types. + </p> + <note> + This is an SPI interface, that should not need to be implemented by any + Spring.NET user. + </note> + </remarks> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry.Wrap(System.Object)"> + <summary> + Returns an <see cref="T:Spring.Aop.IAdvisor"/> wrapping the supplied + <paramref name="advice"/>. + </summary> + <param name="advice"> + The object that should be an advice, such as + <see cref="T:Spring.Aop.IBeforeAdvice"/> or + <see cref="T:Spring.Aop.IThrowsAdvice"/>. + </param> + <returns> + An <see cref="T:Spring.Aop.IAdvisor"/> wrapping the supplied + <paramref name="advice"/>. Never returns <cref lang="null"/>. If + the <paramref name="advice"/> parameter is an + <see cref="T:Spring.Aop.IAdvisor"/>, it will simply be returned. + </returns> + <exception cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"> + If no registered + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> can wrap + the supplied <paramref name="advice"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Returns an <see cref="T:AopAlliance.Intercept.IInterceptor"/> to + allow the use of the supplied <paramref name="advisor"/> in an + interception-based framework. + </summary> + <remarks> + <p> + Don't worry about the pointcut associated with the + <see cref="T:Spring.Aop.IAdvisor"/>; if it's an + <see cref="T:Spring.Aop.IPointcutAdvisor"/>, just return an + interceptor. + </p> + </remarks> + <param name="advisor"> + The advisor to find an interceptor for. + </param> + <returns> + An interceptor to expose this advisor's behaviour. + </returns> + <exception cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"> + If the advisor type is not understood by any registered + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry.RegisterAdvisorAdapter(Spring.Aop.Framework.Adapter.IAdvisorAdapter)"> + <summary> + Register the given <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/>. + </summary> + <remarks> + <p> + Note that it is not necessary to register adapters for + <see cref="T:AopAlliance.Intercept.IInterceptor"/> instances: these + must be automatically recognized by an + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry"/> + implementation. + </p> + </remarks> + <param name="adapter"> + An <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> that + understands the particular advisor and advice types. + </param> + </member> + <member name="M:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry.#ctor"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry"/> class. + </summary> + <remarks> + <p> + This constructor will also register the well-known + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> types. + </p> + </remarks> + <seealso cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> + </member> + <member name="M:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry.Wrap(System.Object)"> + <summary> + Returns an <see cref="T:Spring.Aop.IAdvisor"/> wrapping the supplied + <paramref name="advice"/>. + </summary> + <param name="advice"> + The object that should be an advice, such as + <see cref="T:Spring.Aop.IBeforeAdvice"/> or + <see cref="T:Spring.Aop.IThrowsAdvice"/>. + </param> + <returns> + An <see cref="T:Spring.Aop.IAdvisor"/> wrapping the supplied + <paramref name="advice"/>. Never returns <cref lang="null"/>. If + the <paramref name="advice"/> parameter is an + <see cref="T:Spring.Aop.IAdvisor"/>, it will simply be returned. + </returns> + <exception cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"> + If no registered + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> can wrap + the supplied <paramref name="advice"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Returns an <see cref="T:AopAlliance.Intercept.IInterceptor"/> to + allow the use of the supplied <paramref name="advisor"/> in an + interception-based framework. + </summary> + <param name="advisor">The advisor to find an interceptor for.</param> + <returns> + An interceptor to expose this advisor's behaviour. + </returns> + <exception cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"> + If the advisor type is not understood by any registered + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.DefaultAdvisorAdapterRegistry.RegisterAdvisorAdapter(Spring.Aop.Framework.Adapter.IAdvisorAdapter)"> + <summary> + Register the given <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/>. + </summary> + <param name="adapter"> + An <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> that + understands the particular advisor and advice types. + </param> + </member> + <member name="T:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry"> + <summary> + Provides Singleton-style access to the default + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry"/> instance. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry.#ctor"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry"/> class. + </summary> + <remarks> + <p> + This contructor is marked as <see langword="private"/> to enforce the + Singleton pattern + </p> + </remarks> + </member> + <member name="P:Spring.Aop.Framework.Adapter.GlobalAdvisorAdapterRegistry.Instance"> + <summary> + The default <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapterRegistry"/> instance. + </summary> + </member> + <member name="T:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor"> + <summary> + <see cref="T:AopAlliance.Intercept.IInterceptor"/> implementation that + wraps <see cref="T:Spring.Aop.IMethodBeforeAdvice"/> instances. + </summary> + <remarks> + <p> + In the future Spring.NET may also offer a more efficient alternative + solution in cases where there is no interception advice and therefore + no need to create an <see cref="T:AopAlliance.Intercept.IMethodInvocation"/> + object. + </p> + <p> + Used internally by the Spring.NET AOP framework: application developers + should not need to use this class directly. + </p> + </remarks> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor.#ctor(Spring.Aop.IMethodBeforeAdvice)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor"/> + class. + </summary> + <param name="advice"> + The <see cref="T:Spring.Aop.IMethodBeforeAdvice"/> that is to be wrapped. + </param> + <exception cref="T:System.ArgumentNullException"> + If the supplied <paramref name="advice"/> is <see langword="null"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.MethodBeforeAdviceInterceptor.Invoke(AopAlliance.Intercept.IMethodInvocation)"> + <summary> + Executes interceptor before the target method successfully returns. + </summary> + <param name="invocation"> + The method invocation that is being intercepted. + </param> + <returns> + The result of the call to the + <see cref="M:AopAlliance.Intercept.IJoinpoint.Proceed"/> method of + the supplied <paramref name="invocation"/>. + </returns> + <exception cref="T:System.Exception"> + If any of the interceptors in the chain or the target object itself + throws an exception. + </exception> + </member> + <member name="T:Spring.Aop.Framework.Adapter.ThrowsAdviceAdapter"> + <summary> + <see cref="T:Spring.Aop.Framework.Adapter.IAdvisorAdapter"/> implementation + to enable <see cref="T:Spring.Aop.IThrowsAdvice"/> to be used in the + Spring.NET AOP framework. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceAdapter.SupportsAdvice(AopAlliance.Aop.IAdvice)"> + <summary> + Returns <see langword="true"/> if the supplied + <paramref name="advice"/> is an instance of the + <see cref="T:Spring.Aop.IThrowsAdvice"/> interface. + </summary> + <param name="advice">The advice to check.</param> + <returns> + <see langword="true"/> if the supplied <paramref name="advice"/> is + an instance of the <see cref="T:Spring.Aop.IThrowsAdvice"/> interface; + <see langword="false"/> if not or if the supplied + <paramref name="advice"/> is <cref lang="null"/>. + </returns> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceAdapter.GetInterceptor(Spring.Aop.IAdvisor)"> + <summary> + Wraps the supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> within a + <see cref="T:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor"/> + instance. + </summary> + <param name="advisor"> + The advisor exposing the <see cref="T:AopAlliance.Aop.IAdvice"/> that + is to be wrapped. + </param> + <returns> + The supplied <paramref name="advisor"/>'s + <see cref="P:Spring.Aop.IAdvisor.Advice"/> wrapped within a + <see cref="T:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor"/> + instance. + </returns> + </member> + <member name="T:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor"> + <summary>Interceptor to wrap an after throwing advice.</summary> + <remarks> + <p> + Implementations of the <see cref="T:Spring.Aop.IThrowsAdvice"/> interface + <b>must</b> define methods of the form... + <code lang="C#"> + AfterThrowing([MethodInfo method, Object[] args, Object target], Exception subclass); + </code> + The method name is fixed (i.e. your methods <b>must</b> be named + <c>AfterThrowing</c>. The first three arguments (<i>as a whole</i>) are + optional, and only useful if futher information about the joinpoint is + required. The return type <i>can</i> be anything, but is almost always + <see langword="void"/> by convention. + </p> + <p> + Please note that the object encapsulating the throws advice does not + need to implement the <see cref="T:Spring.Aop.IThrowsAdvice"/> interface. + Throws advice methods are discovered via reflection... the + <see cref="T:Spring.Aop.IThrowsAdvice"/> interface serves merely to + <i>discover</i> objects that are to be considered as throws advice. + Other mechanisms for discovering throws advice such as attributes are + also equally valid... all that this class cares about is that a throws + advice object implement one or more methods with a valid throws advice + signature (see above, and the examples below). + </p> + <p> + This is a framework class that should not normally need to be used + directly by Spring.NET users. + </p> + </remarks> + <example> + <p> + Find below some examples of valid <see cref="T:Spring.Aop.IThrowsAdvice"/> + method signatures... + </p> + <code language="C#"> + public class GlobalExceptionHandlingAdvice : IThrowsAdvice + { + public void AfterThrowing(Exception ex) { + // handles absolutely any and every Exception... + } + } + </code> + <code language="C#"> + public class RemotingExceptionHandlingAdvice : IThrowsAdvice + { + public void AfterThrowing(RemotingException ex) { + // handles any and every RemotingException (and subclasses of RemotingException)... + } + } + </code> + <code language="C#"> + using System.Data; + + public class DataExceptionHandlingAdvice + { + public void AfterThrowing(ConstraintException ex) { + // specialised handling of ConstraintExceptions + } + + public void AfterThrowing(NoNullAllowedException ex) { + // specialised handling of NoNullAllowedExceptions + } + + public void AfterThrowing(DataException ex) { + // handles all other DataExceptions... + } + } + </code> + </example> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + <seealso cref="T:Spring.Aop.IThrowsAdvice"/> + </member> + <member name="F:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.exceptionHandlers"> + <summary> + The mapping of exception Types to MethodInfo handlers. + </summary> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.#ctor(System.Object)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor"/> class. + </summary> + <remarks> + </remarks> + <param name="advice"> + The throws advice to check for exception handler methods. + </param> + <exception cref="T:System.ArgumentNullException"> + If the supplied <paramref name="advice"/> is <see langword="null"/>. + </exception> + <exception cref="T:System.ArgumentException"> + If no (0) handler methods were discovered on the supplied <paramref name="advice"/>; + or if more than one handler method suitable for a particular + <see cref="T:System.Exception"/> type was discovered on the supplied + <paramref name="advice"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.Invoke(AopAlliance.Intercept.IMethodInvocation)"> + <summary> + Executes interceptor if (and only if) the supplied + <paramref name="invocation"/> throws an exception that is mapped to + an appropriate exception handler. + </summary> + <param name="invocation"> + The method invocation that is being intercepted. + </param> + <returns> + The result of the call to the + <see cref="M:AopAlliance.Intercept.IJoinpoint.Proceed"/> method of + the supplied <paramref name="invocation"/> (this assumes no + exception was thrown by the call to the supplied <paramref name="invocation"/>. + </returns> + <exception cref="T:System.Exception"> + If any of the interceptors in the chain or the target object itself + throws an exception. + </exception> + <seealso cref="M:AopAlliance.Intercept.IMethodInterceptor.Invoke(AopAlliance.Intercept.IMethodInvocation)"/> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.GetExceptionHandler(System.Exception)"> + <summary> + Gets the exception handler (if any) that has been mapped to the + supplied <paramref name="exception"/>. + </summary> + <remarks> + <p> + Will return <cref lang="null"/> if not found. + </p> + </remarks> + <returns> + The exception handler for the <see cref="T:System.Type"/> of the + supplied <paramref name="exception"/> given exception. + </returns> + <param name="exception">exception that was thrown</param> + </member> + <member name="M:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.InvokeHandlerMethod(AopAlliance.Intercept.IMethodInvocation,System.Exception,System.Reflection.MethodInfo)"> + <summary> + Invokes handler method with appropriate number of parameters + </summary> + <param name="invocation"> + The original method invocation that was intercepted. + </param> + <param name="triggeringException"> + The exception that triggered this interceptor. + </param> + <param name="handlerMethod"> + The exception handler method to invoke. + </param> + </member> + <member name="P:Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.HandlerMethodCount"> + <summary> + Convenience property that returns the number of exception handler + methods managed by this interceptor. + </summary> + <value> + The number of exception handler methods managed by this interceptor. + </value> + </member> + <member name="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"> + <summary> + Exception thrown when an attempt is made to use an unsupported + <see cref="T:Spring.Aop.IAdvisor"/> or <see cref="T:AopAlliance.Aop.IAdvice"/> + type. + </summary> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException.#ctor(System.Object)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class. + </summary> + <param name="advice">The advice that caused the exception.</param> + </member> + <member name="M:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException.#ctor"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class. + </summary> + </member> + <member name="M:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException.#ctor(System.String)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class with + the specified message. + </summary> + <param name="message"> + A message about the exception. + </param> + </member> + <member name="M:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException.#ctor(System.String,System.Exception)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class with + the specified message and root cause. + </summary> + <param name="message"> + A message about the exception. + </param> + <param name="rootCause"> + The root exception that is being wrapped. + </param> + </member> + <member name="M:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)"> + <summary> + Creates a new instance of the + <see cref="T:Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class. + </summary> + <param name="info"> + The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> + that holds the serialized object data about the exception being thrown. + </param> + <param name="context"> + The <see cref="T:System.Runtime.Serialization.StreamingContext"/> + that contains contextual information about the source or destination. + </param> + </member> + <member name="T:Spring.Aop.Framework.AutoProxy.Target.AbstractPrototypeTargetSourceCreator"> + <summary> + Summary description for AbstractPrototypeBasedTargetSourceCreator. + </summary> + </member> + <member name="T:Spring.Aop.Framework.AutoProxy.ITargetSourceCreator"> + <summary> + Implementations can create special target sources, such as pooling target + sources, for particular objects. For example, they may base their choice + on attributes, such as a pooling attribute, on the target type. + </summary> + <remarks><p>AbstractAutoProxyCreator can support a number of TargetSourceCreators, + which will be applied in order.</p> + </remarks> + <author>Rod Johnson</author> + <author>Adhari C Mahendra (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.AutoProxy.ITargetSourceCreator.GetTargetSource(System.Type,System.String,Spring.Objects.Factory.IObjectFactory)"> + <summary> + Create a special TargetSource for the given object, if any. + </summary> + <param name="objectType">The type of the object to create a TargetSource for</param> + <param name="objectName">the name of the object</param> + <param name="factory">the containing factory</param> + <returns>a special TargetSource or null if this TargetSourceCreator isn't + interested in the particular object</returns> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.Target.AbstractPrototypeTargetSourceCreator.logger"> + <summary> + The logger + </summary> + </member> + <member name="M:Spring.Aop.Framework.AutoProxy.Target.AbstractPrototypeTargetSourceCreator.GetTargetSource(System.Type,System.String,Spring.Objects.Factory.IObjectFactory)"> + <summary> + Create a special TargetSource for the given object, if any. + </summary> + <param name="objectType">the type of the object to create a TargetSource for</param> + <param name="name">the name of the object</param> + <param name="factory">the containing factory</param> + <returns> + a special TargetSource or null if this TargetSourceCreator isn't + interested in the particular object + </returns> + </member> + <member name="M:Spring.Aop.Framework.AutoProxy.Target.AbstractPrototypeTargetSourceCreator.CreatePrototypeTargetSource(System.Type,System.String,Spring.Objects.Factory.IObjectFactory)"> + <summary> + Creates the prototype target source. + </summary> + <param name="objectType">The type of the object to create a target source for.</param> + <param name="name">The name.</param> + <param name="factory">The factory.</param> + <returns></returns> + </member> + <member name="T:Spring.Aop.Framework.AutoProxy.AbstractAdvisorAutoProxyCreator"> + <summary> + Abstract IOBjectPostProcessor implementation that creates AOP proxies. + This class is completely generic; it contains no special code to handle + any particular aspects, such as pooling aspects. + </summary> + <remarks> + <p>Subclasses must implement the abstract findCandidateAdvisors() method + to return a list of Advisors applying to any object. Subclasses can also + override the inherited shouldSkip() method to exclude certain objects + from autoproxying, but they must be careful to invoke the shouldSkip() + method of this class, which tries to avoid circular reference problems + and infinite loops.</p> + <p>Advisors or advices requiring ordering should implement the Ordered interface. + This class sorts advisors by Ordered order value. Advisors that don't implement + the Ordered interface will be considered to be unordered, and will appear + at the end of the advisor chain in undefined order.</p> + </remarks> + <seealso cref="M:Spring.Aop.Framework.AutoProxy.AbstractAdvisorAutoProxyCreator.FindCandidateAdvisors"/> + <author>Rod Johnson</author> + <author>Adhari C Mahendra (.NET)</author> + </member> + <member name="T:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator"> + <summary> + ObjectPostProcessor implementation that wraps a group of objects with AOP proxies + that delegate to the given interceptors before invoking the object itself. + </summary> + <remarks> + <p>This class distinguishes between "common" interceptors: shared for all proxies it + creates, and "specific" interceptors: unique per object instance. There need not + be any common interceptors. If there are, they are set using the interceptorNames + property. As with ProxyFactoryObject, interceptors names in the current factory + are used rather than object references to allow correct handling of prototype + advisors and interceptors: for example, to support stateful mixins. + Any advice type is supported for "interceptorNames" entries.</p> + <p>Such autoproxying is particularly useful if there's a large number of objects that need + to be wrapped with similar proxies, i.e. delegating to the same interceptors. + Instead of x repetitive proxy definitions for x target objects, you can register + one single such post processor with the object factory to achieve the same effect.</p> + <p>Subclasses can apply any strategy to decide if a object is to be proxied, + e.g. by type, by name, by definition details, etc. They can also return + additional interceptors that should just be applied to the specific object + instance. The default concrete implementation is ObjectNameAutoProxyCreator, + identifying the objects to be proxied via a list of object names.</p> + <p>Any number of TargetSourceCreator implementations can be used with any subclass, + to create a custom target source - for example, to pool prototype objects. + Autoproxying will occur even if there is no advice if a TargetSourceCreator specifies + a custom TargetSource. If there are no TargetSourceCreators set, or if none matches, + a SingletonTargetSource will be used by default to wrap the object to be autoproxied.</p> + </remarks> + <author>Juergen Hoeller</author> + <author>Rod Johnson</author> + <author>Adhari C Mahendra (.NET)</author> + <seealso cref="P:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.InterceptorNames"/> + <seealso cref="T:Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator"/> + </member> + <member name="T:Spring.Aop.Framework.ProxyConfig"> + <summary> + Convenience superclass for configuration used in creating proxies, + to ensure that all proxy creators have consistent properties. + </summary> + <remarks> + <p> + Note that it is no longer possible to configure subclasses to + expose the <see cref="T:AopAlliance.Intercept.IMethodInvocation"/>. + Interceptors should normally manage their own thread locals if they + need to make resources available to advised objects. If it is + absolutely necessary to expose the + <see cref="T:AopAlliance.Intercept.IMethodInvocation"/>, use an + interceptor to do so. + </p> + </remarks> + <author>Rod Johnson</author> + <author>Aleksandar Seovic (.NET)</author> + </member> + <member name="M:Spring.Aop.Framework.ProxyConfig.CopyFrom(Spring.Aop.Framework.ProxyConfig)"> + <summary> + Copies the configuration from the supplied + <paramref name="otherConfiguration"/> into this instance. + </summary> + <param name="otherConfiguration"> + The configuration to be copied. + </param> + <exception cref="T:System.ArgumentNullException"> + If the supplied <paramref name="otherConfiguration"/> is + <see langword="null"/>. + </exception> + </member> + <member name="M:Spring.Aop.Framework.ProxyConfig.ToString"> + <summary> + A <see cref="T:System.String"/> that represents the current + <see cref="T:Spring.Aop.Framework.ProxyConfig"/> configuration. + </summary> + <returns> + A <see cref="T:System.String"/> that represents the current + <see cref="T:Spring.Aop.Framework.ProxyConfig"/> configuration. + </returns> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.SyncRoot"> + <summary> + Use to synchronize access to this ProxyConfig instance + </summary> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.ProxyTargetType"> + <summary> + Is the target <see cref="T:System.Type"/> to be proxied in addition + to any interfaces declared on the proxied <see cref="T:System.Type"/>? + </summary> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.ProxyTargetAttributes"> + <summary> + Is target type attributes, method attributes, method's return type attributes + and method's parameter attributes to be proxied in addition + to any interfaces declared on the proxied <see cref="T:System.Type"/>? + </summary> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.Optimize"> + <summary> + Are any <i>agressive optimizations</i> to be performed? + </summary> + <remarks> + <p> + The exact meaning of <i>agressive optimizations</i> will differ + between proxies, but there is usually some tradeoff. + </p> + <p> + For example, optimization will usually mean that advice changes + won't take effect after a proxy has been created. For this reason, + optimization is disabled by default. An optimize value of + <see langword="true"/> may be ignored if other settings preclude + optimization: for example, if the + <see cref="P:Spring.Aop.Framework.ProxyConfig.ExposeProxy"/> property + is set to <see langword="true"/> and such a value is not compatible + with the optimization. + </p> + <p> + The default is <see langword="false"/>. + </p> + </remarks> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.ExposeProxy"> + <summary> + Should proxies obtained from this configuration expose + the AOP proxy to the + <see cref="T:Spring.Aop.Framework.AopContext"/> class? + </summary> + <remarks> + <p> + The default is <see langword="false"/>, as enabling this property + may impair performance. + </p> + </remarks> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.AopProxyFactory"> + <summary> + Gets and set the factory to be used to create AOP proxies. + </summary> + <remarks> + <p> + This obviously allows one to customise the + <see cref="T:Spring.Aop.Framework.IAopProxyFactory"/> implementation, + allowing different strategies to be dropped in without changing the + core framework. For example, an + <see cref="T:Spring.Aop.Framework.IAopProxyFactory"/> implementation + could return an <see cref="T:Spring.Aop.Framework.IAopProxy"/> + using remoting proxies, <c>Reflection.Emit</c> or a code generation + strategy. + </p> + </remarks> + </member> + <member name="P:Spring.Aop.Framework.ProxyConfig.IsFrozen"> + <summary> + Is this configuration frozen? + </summary> + <remarks> + <p> + The default is not frozen. + </p> + </remarks> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.logger"> + <summary> + The logger for this class hierarchy. + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.DO_NOT_PROXY"> + <summary> + Convenience constant for subclasses: Return value for "do not proxy". + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS"> + <summary> + Convenience constant for subclasses: Return value for + "proxy without additional interceptors, just the common ones". + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.order"> + <summary> + Default value is same as non-ordered + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.advisorAdapterRegistry"> + <summary> + Default is global AdvisorAdapterRegistry + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.freezeProxy"> + <summary> + + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCreator.interceptorNames"> + <summary> + Names of common interceptors. + We must use object name rather than object references + to handle prototype advisors/interceptors. + Default is the empty array: no common interceptors. + </summary> + </member> + <member name="F:Spring.Aop.Framework.AutoProxy.AbstractA... [truncated message content] |
From: <fab...@us...> - 2009-05-09 03:04:34
|
Revision: 4272 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4272&view=rev Author: fabiomaulo Date: 2009-05-09 03:04:15 +0000 (Sat, 09 May 2009) Log Message: ----------- - Minor (QueryLoader checked) - added transformer Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/HolderInstantiator.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Transform/Transformers.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Transform/ToListResultTransformer.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-09 02:27:10 UTC (rev 4271) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-09 03:04:15 UTC (rev 4272) @@ -234,11 +234,7 @@ //sqlResultTypes = selectClause.getSqlResultTypes(); _queryReturnTypes = selectClause.QueryReturnTypes; - _selectNewTransformer = HolderInstantiator.CreateSelectNewTransformer(selectClause.Constructor, selectClause.IsMap); - - // TODO - Java implementation passes IsList into CreateSelectNewTransformer..., - // selectClause.IsList); - + _selectNewTransformer = HolderInstantiator.CreateSelectNewTransformer(selectClause.Constructor, selectClause.IsMap, selectClause.IsList); _queryReturnAliases = selectClause.QueryReturnAliases; IList<FromElement> collectionFromElements = selectClause.CollectionFromElements; @@ -426,6 +422,7 @@ internal IEnumerable GetEnumerable(QueryParameters queryParameters, ISessionImplementor session) { + CheckQuery(queryParameters); bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); Modified: trunk/nhibernate/src/NHibernate/Hql/HolderInstantiator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/HolderInstantiator.cs 2009-05-09 02:27:10 UTC (rev 4271) +++ trunk/nhibernate/src/NHibernate/Hql/HolderInstantiator.cs 2009-05-09 03:04:15 UTC (rev 4272) @@ -1,4 +1,3 @@ -using System; using System.Reflection; using NHibernate.Transform; @@ -8,8 +7,8 @@ { public static readonly HolderInstantiator NoopInstantiator = new HolderInstantiator(null, null); - private IResultTransformer transformer; - private string[] queryReturnAliases; + private readonly IResultTransformer transformer; + private readonly string[] queryReturnAliases; public static HolderInstantiator GetHolderInstantiator(IResultTransformer selectNewTransformer, IResultTransformer customTransformer, @@ -25,7 +24,8 @@ } } - public static IResultTransformer CreateSelectNewTransformer(ConstructorInfo constructor, bool returnMaps) + public static IResultTransformer CreateSelectNewTransformer(ConstructorInfo constructor, bool returnMaps, + bool returnLists) { if (constructor != null) { @@ -35,6 +35,10 @@ { return Transformers.AliasToEntityMap; } + else if (returnLists) + { + return Transformers.ToList; + } else { return null; @@ -54,10 +58,7 @@ } } - public HolderInstantiator( - IResultTransformer transformer, - string[] queryReturnAliases - ) + public HolderInstantiator(IResultTransformer transformer, string[] queryReturnAliases) { this.transformer = transformer; this.queryReturnAliases = queryReturnAliases; Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-09 02:27:10 UTC (rev 4271) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-09 03:04:15 UTC (rev 4272) @@ -593,6 +593,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> <Compile Include="Param\VersionTypeSeedParameterSpecification.cs" /> <Compile Include="SqlCommand\InsertSelect.cs" /> + <Compile Include="Transform\ToListResultTransformer.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/Transform/ToListResultTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Transform/ToListResultTransformer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Transform/ToListResultTransformer.cs 2009-05-09 03:04:15 UTC (rev 4272) @@ -0,0 +1,23 @@ +using System; +using System.Collections; + +namespace NHibernate.Transform +{ + /// <summary> + /// Tranforms each result row from a tuple into a <see cref="IList"/>, such that what + /// you end up with is a <see cref="IList"/> of <see cref="IList"/>. + /// </summary> + [Serializable] + public class ToListResultTransformer : IResultTransformer + { + public object TransformTuple(object[] tuple, string[] aliases) + { + return new ArrayList(tuple); + } + + public IList TransformList(IList list) + { + return list; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Transform/Transformers.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Transform/Transformers.cs 2009-05-09 02:27:10 UTC (rev 4271) +++ trunk/nhibernate/src/NHibernate/Transform/Transformers.cs 2009-05-09 03:04:15 UTC (rev 4272) @@ -13,6 +13,9 @@ /// </summary> public static readonly IResultTransformer AliasToEntityMap = new AliasToEntityMapResultTransformer(); + /// <summary> Each row of results is a <see cref="IList"/></summary> + public static readonly ToListResultTransformer ToList = new ToListResultTransformer(); + /// <summary> /// Creates a resulttransformer that will inject aliased values into instances /// of <paramref name="target"/> via property methods or fields. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-09 02:27:13
|
Revision: 4271 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4271&view=rev Author: fabiomaulo Date: 2009-05-09 02:27:10 +0000 (Sat, 09 May 2009) Log Message: ----------- Minor (reformatting) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-08 16:40:47 UTC (rev 4270) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-09 02:27:10 UTC (rev 4271) @@ -14,7 +14,6 @@ using NHibernate.Transform; using NHibernate.Type; using NHibernate.Util; -using IQueryable=NHibernate.Persister.Entity.IQueryable; namespace NHibernate.Hql.Ast.ANTLR.Loader { @@ -40,11 +39,12 @@ private bool[] _includeInSelect; private int[] _owners; private EntityType[] _ownerAssociationTypes; - private readonly NullableDictionary<string, string> _sqlAliasByEntityAlias= new NullableDictionary<string, string>(); + private readonly NullableDictionary<string, string> _sqlAliasByEntityAlias = new NullableDictionary<string, string>(); private int _selectLength; private LockMode[] _defaultLockModes; - public QueryLoader(QueryTranslatorImpl queryTranslator, ISessionFactoryImplementor factory, SelectClause selectClause) : base(factory) + public QueryLoader(QueryTranslatorImpl queryTranslator, ISessionFactoryImplementor factory, SelectClause selectClause) + : base(factory) { _queryTranslator = queryTranslator; _selectClause = selectClause; @@ -58,15 +58,15 @@ get { return HasSubselectLoadableCollections(); } } + protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) + { + _queryTranslator.AdjustNamedParameterLocationsForQueryParameters(parameters); + } - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - _queryTranslator.AdjustNamedParameterLocationsForQueryParameters(parameters); - } - - protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMode> lockModes, Dialect.Dialect dialect) + protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMode> lockModes, + Dialect.Dialect dialect) { - if ( lockModes == null || lockModes.Count == 0 ) + if (lockModes == null || lockModes.Count == 0) { return sql; } @@ -74,16 +74,16 @@ // can't cache this stuff either (per-invocation) // we are given a map of user-alias -> lock mode // create a new map of sql-alias -> lock mode - Dictionary<string, LockMode> aliasedLockModes = new Dictionary<string, LockMode>(); + var aliasedLockModes = new Dictionary<string, LockMode>(); Dictionary<string, string[]> keyColumnNames = dialect.ForUpdateOfColumns ? new Dictionary<string, string[]>() : null; foreach (var entry in lockModes) { string userAlias = entry.Key; string drivingSqlAlias = _sqlAliasByEntityAlias[userAlias]; - if ( drivingSqlAlias == null ) + if (drivingSqlAlias == null) { - throw new InvalidOperationException( "could not locate alias to apply lock mode : " + userAlias ); + throw new InvalidOperationException("could not locate alias to apply lock mode : " + userAlias); } // at this point we have (drivingSqlAlias) the SQL alias of the driving table @@ -92,27 +92,28 @@ // the exception case here is joined-subclass hierarchies where we instead // want to apply the lock against the root table (for all other strategies, // it just happens that driving and root are the same). - QueryNode select = ( QueryNode ) _queryTranslator.SqlAST; - ILockable drivingPersister = ( ILockable ) select.FromClause.GetFromElement( userAlias ).Queryable; - string sqlAlias = drivingPersister.GetRootTableAlias( drivingSqlAlias ); + var select = (QueryNode) _queryTranslator.SqlAST; + var drivingPersister = (ILockable) select.FromClause.GetFromElement(userAlias).Queryable; + string sqlAlias = drivingPersister.GetRootTableAlias(drivingSqlAlias); aliasedLockModes.Add(sqlAlias, entry.Value); - if ( keyColumnNames != null ) + if (keyColumnNames != null) { - keyColumnNames.Add( sqlAlias, drivingPersister.RootTableIdentifierColumnNames ); + keyColumnNames.Add(sqlAlias, drivingPersister.RootTableIdentifierColumnNames); } } - return dialect.ApplyLocksToSql( sql, aliasedLockModes, keyColumnNames ); + return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames); } - protected override int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, int startIndex, ISessionImplementor session) + protected override int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, int startIndex, + ISessionImplementor session) { int position = startIndex; - + IList<IParameterSpecification> parameterSpecs = _queryTranslator.CollectedParameterSpecifications; - foreach (IParameterSpecification spec in parameterSpecs) + foreach (var spec in parameterSpecs) { position += spec.Bind(statement, queryParameters, session, position); } @@ -182,16 +183,16 @@ // it is per-invocation, not constant for the // QueryTranslator instance - LockMode[] lockModeArray = new LockMode[_entityAliases.Length]; + var lockModeArray = new LockMode[_entityAliases.Length]; for (int i = 0; i < _entityAliases.Length; i++) { LockMode lockMode; - if (!lockModes.TryGetValue(_entityAliases[i], out lockMode)) - { + if (!lockModes.TryGetValue(_entityAliases[i], out lockMode)) + { //NONE, because its the requested lock mode, not the actual! lockMode = LockMode.None; - } + } lockModeArray[i] = lockMode; } @@ -233,30 +234,28 @@ //sqlResultTypes = selectClause.getSqlResultTypes(); _queryReturnTypes = selectClause.QueryReturnTypes; - _selectNewTransformer = HolderInstantiator.CreateSelectNewTransformer( - selectClause.Constructor, - selectClause.IsMap); - + _selectNewTransformer = HolderInstantiator.CreateSelectNewTransformer(selectClause.Constructor, selectClause.IsMap); + // TODO - Java implementation passes IsList into CreateSelectNewTransformer..., // selectClause.IsList); _queryReturnAliases = selectClause.QueryReturnAliases; IList<FromElement> collectionFromElements = selectClause.CollectionFromElements; - if ( collectionFromElements != null && collectionFromElements.Count !=0 ) + if (collectionFromElements != null && collectionFromElements.Count != 0) { int length = collectionFromElements.Count; _collectionPersisters = new IQueryableCollection[length]; _collectionOwners = new int[length]; _collectionSuffixes = new string[length]; - for ( int i=0; i<length; i++ ) + for (int i = 0; i < length; i++) { FromElement collectionFromElement = collectionFromElements[i]; _collectionPersisters[i] = collectionFromElement.QueryableCollection; _collectionOwners[i] = fromElementList.IndexOf(collectionFromElement.Origin); - // collectionSuffixes[i] = collectionFromElement.getColumnAliasSuffix(); - // collectionSuffixes[i] = Integer.toString( i ) + "_"; + // collectionSuffixes[i] = collectionFromElement.getColumnAliasSuffix(); + // collectionSuffixes[i] = Integer.toString( i ) + "_"; _collectionSuffixes[i] = collectionFromElement.CollectionSuffix; } } @@ -271,42 +270,42 @@ _owners = new int[size]; _ownerAssociationTypes = new EntityType[size]; - for ( int i = 0; i < size; i++ ) + for (int i = 0; i < size; i++) { FromElement element = fromElementList[i]; - _entityPersisters[i] = ( IQueryable ) element.EntityPersister; + _entityPersisters[i] = (IQueryable) element.EntityPersister; - if ( _entityPersisters[i] == null ) + if (_entityPersisters[i] == null) { - throw new InvalidOperationException( "No entity persister for " + element.ToString() ); + throw new InvalidOperationException("No entity persister for " + element); } _entityEagerPropertyFetches[i] = element.IsAllPropertyFetch; _sqlAliases[i] = element.TableAlias; _entityAliases[i] = element.ClassAlias; - _sqlAliasByEntityAlias.Add( _entityAliases[i], _sqlAliases[i] ); + _sqlAliasByEntityAlias.Add(_entityAliases[i], _sqlAliases[i]); // TODO should we just collect these like with the collections above? - _sqlAliasSuffixes[i] = ( size == 1 ) ? "" : i.ToString() + "_"; - // sqlAliasSuffixes[i] = element.getColumnAliasSuffix(); + _sqlAliasSuffixes[i] = (size == 1) ? "" : i + "_"; + // sqlAliasSuffixes[i] = element.getColumnAliasSuffix(); _includeInSelect[i] = !element.IsFetch; - if ( _includeInSelect[i] ) + if (_includeInSelect[i]) { _selectLength++; } _owners[i] = -1; //by default - if ( element.IsFetch ) + if (element.IsFetch) { - if ( element.IsCollectionJoin || element.QueryableCollection != null ) + if (element.IsCollectionJoin || element.QueryableCollection != null) { // This is now handled earlier in this method. } - else if ( element.DataType.IsEntityType ) + else if (element.DataType.IsEntityType) { - EntityType entityType = ( EntityType ) element.DataType; - if ( entityType.IsOneToOne) + var entityType = (EntityType) element.DataType; + if (entityType.IsOneToOne) { - _owners[i] = fromElementList.IndexOf( element.Origin ); + _owners[i] = fromElementList.IndexOf(element.Origin); } _ownerAssociationTypes[i] = entityType; } @@ -317,41 +316,44 @@ _defaultLockModes = ArrayHelper.FillArray(LockMode.None, size); } - public IList List(ISessionImplementor session, QueryParameters queryParameters) + public IList List(ISessionImplementor session, QueryParameters queryParameters) { - CheckQuery( queryParameters ); - return List( session, queryParameters, _queryTranslator.QuerySpaces, _queryReturnTypes ); + CheckQuery(queryParameters); + return List(session, queryParameters, _queryTranslator.QuerySpaces, _queryReturnTypes); } - protected override IList GetResultList(IList results, IResultTransformer resultTransformer) - { - // meant to handle dynamic instantiation queries... - HolderInstantiator holderInstantiator = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer, resultTransformer, _queryReturnAliases); - if (holderInstantiator.IsRequired) - { - for (int i = 0; i < results.Count; i++) - { - Object[] row = (Object[])results[i]; - Object result = holderInstantiator.Instantiate(row); - results[i] = result; - } + protected override IList GetResultList(IList results, IResultTransformer resultTransformer) + { + // meant to handle dynamic instantiation queries... + HolderInstantiator holderInstantiator = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer, + resultTransformer, + _queryReturnAliases); + if (holderInstantiator.IsRequired) + { + for (int i = 0; i < results.Count; i++) + { + var row = (Object[]) results[i]; + Object result = holderInstantiator.Instantiate(row); + results[i] = result; + } - if (!HasSelectNew && resultTransformer != null) - { - return resultTransformer.TransformList(results); - } - else - { - return results; - } - } - else - { - return results; - } - } + if (!HasSelectNew && resultTransformer != null) + { + return resultTransformer.TransformList(results); + } + else + { + return results; + } + } + else + { + return results; + } + } - protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, ISessionImplementor session) + protected override object GetResultColumnOrRow(object[] row, IResultTransformer resultTransformer, IDataReader rs, + ISessionImplementor session) { row = ToResultRow(row); bool hasTransform = HasSelectNew || resultTransformer != null; @@ -392,7 +394,7 @@ return row; } - object[] result = new object[_selectLength]; + var result = new object[_selectLength]; int j = 0; for (int i = 0; i < row.Length; i++) { @@ -435,13 +437,15 @@ IDbCommand cmd = PrepareQueryCommand(queryParameters, false, session); // This IDataReader is disposed of in EnumerableImpl.Dispose - IDataReader rs = GetResultSet(cmd, queryParameters.HasAutoDiscoverScalarTypes, false, queryParameters.RowSelection, session); + IDataReader rs = GetResultSet(cmd, queryParameters.HasAutoDiscoverScalarTypes, false, queryParameters.RowSelection, + session); - HolderInstantiator hi = - HolderInstantiator.GetHolderInstantiator(_selectNewTransformer, queryParameters.ResultTransformer, _queryReturnAliases); + HolderInstantiator hi = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer, + queryParameters.ResultTransformer, + _queryReturnAliases); - IEnumerable result = - new EnumerableImpl(rs, cmd, session, _queryTranslator.ReturnTypes, _queryTranslator.GetColumnNames(), queryParameters.RowSelection, hi); + IEnumerable result = new EnumerableImpl(rs, cmd, session, _queryTranslator.ReturnTypes, + _queryTranslator.GetColumnNames(), queryParameters.RowSelection, hi); if (statsEnabled) { @@ -454,4 +458,4 @@ return result; } } -} +} \ 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-08 16:40:53
|
Revision: 4270 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4270&view=rev Author: fabiomaulo Date: 2009-05-08 16:40:47 +0000 (Fri, 08 May 2009) Log Message: ----------- Fixed the query syntax for the new parser Modified Paths: -------------- trunk/nhibernate/releasenotes.txt trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2009-05-08 16:07:27 UTC (rev 4269) +++ trunk/nhibernate/releasenotes.txt 2009-05-08 16:40:47 UTC (rev 4270) @@ -9,6 +9,7 @@ * In SchemaExport.Execute the parameter "format" was removed; (NH-1701) enabled configuration property format_sql (default true) * Antlr3.Runtime.dll is required * the syntax foo.bar.baz.elements or foo.bar.baz.indices is not longer supported. Use the alternative syntax of elements(foo.bar.baz) or indices(foo.bar.baz) instead + Note: in some case, where a sub-select is needed, the collection is enough example: FROM m IN CLASS Master WHERE NOT EXISTS( FROM m.Details d WHERE NOT d.I=5 ) ##### Possible Breaking Changes for external frameworks ##### * ISession interface has additional methods Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-08 16:07:27 UTC (rev 4269) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/MasterDetailTest.cs 2009-05-08 16:40:47 UTC (rev 4270) @@ -366,11 +366,11 @@ ISession s = OpenSession(); ITransaction t = s.BeginTransaction(); - string path = IsClassicParser ? "m.Details.elements" : "elements(m.Details)"; + string path = IsClassicParser ? "m.Details.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 EXISTS ( FROM " + path + " d 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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-08 16:07:28
|
Revision: 4269 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4269&view=rev Author: fabiomaulo Date: 2009-05-08 16:07:27 +0000 (Fri, 08 May 2009) Log Message: ----------- With clause on air Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs 2009-05-08 15:37:38 UTC (rev 4268) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs 2009-05-08 16:07:27 UTC (rev 4269) @@ -4,7 +4,7 @@ namespace NHibernate.Test.HQL.Ast { - [TestFixture, Ignore("Not suported yet.")] + [TestFixture] public class WithClauseFixture : BaseFixture { public ISession OpenNewSession() @@ -21,8 +21,8 @@ ISession s = OpenSession(); ITransaction txn = s.BeginTransaction(); - Assert.Throws<HibernateException>( - () => + Assert.Throws<SemanticException>( + () => s.CreateQuery("from Animal a inner join fetch a.offspring as o with o.bodyWeight = :someLimit").SetDouble( "someLimit", 1).List(), "ad-hoc on clause allowed with fetched association"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-08 15:37:42
|
Revision: 4268 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4268&view=rev Author: steverstrong Date: 2009-05-08 15:37:38 +0000 (Fri, 08 May 2009) Log Message: ----------- Fixed bug with "With" clause handling in the AST parser Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-05-08 12:01:51 UTC (rev 4267) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-05-08 15:37:38 UTC (rev 4268) @@ -1,9375 +1,9436 @@ -// $ANTLR 3.1.2 C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g 2009-05-06 18:27:40 - -// The variable 'variable' is assigned but its value is never used. -#pragma warning disable 168, 219 -// Unreachable code detected. -#pragma warning disable 162 -namespace NHibernate.Hql.Ast.ANTLR -{ - -using System.Text; -using NHibernate.Hql.Ast.ANTLR.Tree; - - -using System; -using Antlr.Runtime; -using Antlr.Runtime.Tree;using IList = System.Collections.IList; -using ArrayList = System.Collections.ArrayList; -using Stack = Antlr.Runtime.Collections.StackList; - - - -public partial class HqlSqlWalker : TreeParser -{ - public static readonly string[] tokenNames = new string[] - { - "<invalid>", - "<EOR>", - "<DOWN>", - "<UP>", - "ALL", - "ANY", - "AND", - "AS", - "ASCENDING", - "AVG", - "BETWEEN", - "CLASS", - "COUNT", - "DELETE", - "DESCENDING", - "DOT", - "DISTINCT", - "ELEMENTS", - "ESCAPE", - "EXISTS", - "FALSE", - "FETCH", - "FROM", - "FULL", - "GROUP", - "HAVING", - "IN", - "INDICES", - "INNER", - "INSERT", - "INTO", - "IS", - "JOIN", - "LEFT", - "LIKE", - "MAX", - "MIN", - "NEW", - "NOT", - "NULL", - "OR", - "ORDER", - "OUTER", - "PROPERTIES", - "RIGHT", - "SELECT", - "SET", - "SOME", - "SUM", - "TRUE", - "UNION", - "UPDATE", - "VERSIONED", - "WHERE", - "LITERAL_by", - "CASE", - "END", - "ELSE", - "THEN", - "WHEN", - "ON", - "WITH", - "BOTH", - "EMPTY", - "LEADING", - "MEMBER", - "OBJECT", - "OF", - "TRAILING", - "AGGREGATE", - "ALIAS", - "CONSTRUCTOR", - "CASE2", - "EXPR_LIST", - "FILTER_ENTITY", - "IN_LIST", - "INDEX_OP", - "IS_NOT_NULL", - "IS_NULL", - "METHOD_CALL", - "NOT_BETWEEN", - "NOT_IN", - "NOT_LIKE", - "ORDER_ELEMENT", - "QUERY", - "RANGE", - "ROW_STAR", - "SELECT_FROM", - "UNARY_MINUS", - "UNARY_PLUS", - "VECTOR_EXPR", - "WEIRD_IDENT", - "CONSTANT", - "NUM_INT", - "NUM_DOUBLE", - "NUM_FLOAT", - "NUM_LONG", - "JAVA_CONSTANT", - "COMMA", - "EQ", - "OPEN", - "CLOSE", - "NE", - "SQL_NE", - "LT", - "GT", - "LE", - "GE", - "CONCAT", - "PLUS", - "MINUS", - "STAR", - "DIV", - "OPEN_BRACKET", - "CLOSE_BRACKET", - "COLON", - "PARAM", - "QUOTED_String", - "IDENT", - "ID_START_LETTER", - "ID_LETTER", - "ESCqs", - "WS", - "EXPONENT", - "FLOAT_SUFFIX", - "HEX_DIGIT", - "'ascending'", - "'descending'", - "FROM_FRAGMENT", - "IMPLIED_FROM", - "JOIN_FRAGMENT", - "SELECT_CLAUSE", - "LEFT_OUTER", - "RIGHT_OUTER", - "ALIAS_REF", - "PROPERTY_REF", - "SQL_TOKEN", - "SELECT_COLUMNS", - "SELECT_EXPR", - "THETA_JOINS", - "FILTERS", - "METHOD_NAME", - "NAMED_PARAM", - "BOGUS" - }; - - public const int SELECT_COLUMNS = 137; - public const int LT = 104; - public const int EXPONENT = 123; - public const int STAR = 111; - public const int FLOAT_SUFFIX = 124; - public const int FILTERS = 140; - public const int LITERAL_by = 54; - public const int PROPERTY_REF = 135; - public const int THETA_JOINS = 139; - public const int CASE = 55; - public const int NEW = 37; - public const int FILTER_ENTITY = 74; - public const int PARAM = 116; - public const int COUNT = 12; - public const int NOT = 38; - public const int EOF = -1; - public const int UNARY_PLUS = 89; - public const int QUOTED_String = 117; - public const int ESCqs = 121; - public const int WEIRD_IDENT = 91; - public const int OPEN_BRACKET = 113; - public const int FULL = 23; - public const int ORDER_ELEMENT = 83; - public const int IS_NULL = 78; - public const int ESCAPE = 18; - public const int INSERT = 29; - public const int FROM_FRAGMENT = 128; - public const int NAMED_PARAM = 142; - public const int BOTH = 62; - public const int SELECT_CLAUSE = 131; - public const int VERSIONED = 52; - public const int EQ = 99; - public const int SELECT = 45; - public const int INTO = 30; - public const int NE = 102; - public const int GE = 107; - public const int CONCAT = 108; - public const int ID_LETTER = 120; - public const int NULL = 39; - public const int ELSE = 57; - public const int SELECT_FROM = 87; - public const int TRAILING = 68; - public const int ON = 60; - public const int NUM_LONG = 96; - public const int NUM_DOUBLE = 94; - public const int UNARY_MINUS = 88; - public const int DELETE = 13; - public const int INDICES = 27; - public const int OF = 67; - public const int METHOD_CALL = 79; - public const int LEADING = 64; - public const int METHOD_NAME = 141; - public const int EMPTY = 63; - public const int T__126 = 126; - public const int GROUP = 24; - public const int T__127 = 127; - public const int WS = 122; - public const int FETCH = 21; - public const int VECTOR_EXPR = 90; - public const int NOT_IN = 81; - public const int SELECT_EXPR = 138; - public const int NUM_INT = 93; - public const int OR = 40; - public const int ALIAS = 70; - public const int JAVA_CONSTANT = 97; - public const int CONSTANT = 92; - public const int GT = 105; - public const int QUERY = 84; - public const int INDEX_OP = 76; - public const int NUM_FLOAT = 95; - public const int FROM = 22; - public const int END = 56; - public const int FALSE = 20; - public const int DISTINCT = 16; - public const int CONSTRUCTOR = 71; - public const int CLOSE_BRACKET = 114; - public const int WHERE = 53; - public const int CLASS = 11; - public const int MEMBER = 65; - public const int INNER = 28; - public const int PROPERTIES = 43; - public const int BOGUS = 143; - public const int ORDER = 41; - public const int MAX = 35; - public const int UPDATE = 51; - public const int JOIN_FRAGMENT = 130; - public const int SQL_NE = 103; - public const int AND = 6; - public const int SUM = 48; - public const int ASCENDING = 8; - public const int EXPR_LIST = 73; - public const int AS = 7; - public const int IN = 26; - public const int THEN = 58; - public const int OBJECT = 66; - public const int COMMA = 98; - public const int SQL_TOKEN = 136; - public const int IS = 31; - public const int LEFT = 33; - public const int AVG = 9; - public const int SOME = 47; - public const int ALL = 4; - public const int IMPLIED_FROM = 129; - public const int IDENT = 118; - public const int CASE2 = 72; - public const int PLUS = 109; - public const int EXISTS = 19; - public const int DOT = 15; - public const int WITH = 61; - public const int LIKE = 34; - public const int OUTER = 42; - public const int ID_START_LETTER = 119; - public const int LEFT_OUTER = 132; - public const int ROW_STAR = 86; - public const int NOT_LIKE = 82; - public const int RIGHT_OUTER = 133; - public const int RANGE = 85; - public const int NOT_BETWEEN = 80; - public const int HEX_DIGIT = 125; - public const int SET = 46; - public const int RIGHT = 44; - public const int HAVING = 25; - public const int MIN = 36; - public const int IS_NOT_NULL = 77; - public const int MINUS = 110; - public const int ELEMENTS = 17; - public const int TRUE = 49; - public const int JOIN = 32; - public const int IN_LIST = 75; - public const int UNION = 50; - public const int OPEN = 100; - public const int COLON = 115; - public const int ANY = 5; - public const int CLOSE = 101; - public const int WHEN = 59; - public const int ALIAS_REF = 134; - public const int DIV = 112; - public const int DESCENDING = 14; - public const int AGGREGATE = 69; - public const int BETWEEN = 10; - public const int LE = 106; - - // delegates - // delegators - - - - public HqlSqlWalker(ITreeNodeStream input) - : this(input, new RecognizerSharedState()) { - } - - public HqlSqlWalker(ITreeNodeStream input, RecognizerSharedState state) - : base(input, state) { - InitializeCyclicDFAs(); - - - } - - protected ITreeAdaptor adaptor = new CommonTreeAdaptor(); - - public ITreeAdaptor TreeAdaptor - { - get { return this.adaptor; } - set { - this.adaptor = value; - } - } - - override public string[] TokenNames { - get { return HqlSqlWalker.tokenNames; } - } - - override public string GrammarFileName { - get { return "C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g"; } - } - - - public class statement_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "statement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:40:1: statement : ( selectStatement | updateStatement | deleteStatement | insertStatement ); - public HqlSqlWalker.statement_return statement() // throws RecognitionException [1] - { - HqlSqlWalker.statement_return retval = new HqlSqlWalker.statement_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - HqlSqlWalker.selectStatement_return selectStatement1 = default(HqlSqlWalker.selectStatement_return); - - HqlSqlWalker.updateStatement_return updateStatement2 = default(HqlSqlWalker.updateStatement_return); - - HqlSqlWalker.deleteStatement_return deleteStatement3 = default(HqlSqlWalker.deleteStatement_return); - - HqlSqlWalker.insertStatement_return insertStatement4 = default(HqlSqlWalker.insertStatement_return); - - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:41:2: ( selectStatement | updateStatement | deleteStatement | insertStatement ) - int alt1 = 4; - switch ( input.LA(1) ) - { - case QUERY: - { - alt1 = 1; - } - break; - case UPDATE: - { - alt1 = 2; - } - break; - case DELETE: - { - alt1 = 3; - } - break; - case INSERT: - { - alt1 = 4; - } - break; - default: - NoViableAltException nvae_d1s0 = - new NoViableAltException("", 1, 0, input); - - throw nvae_d1s0; - } - - switch (alt1) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:41:4: selectStatement - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectStatement_in_statement168); - selectStatement1 = selectStatement(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, selectStatement1.Tree); - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:41:22: updateStatement - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_updateStatement_in_statement172); - updateStatement2 = updateStatement(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, updateStatement2.Tree); - - } - break; - case 3 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:41:40: deleteStatement - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_deleteStatement_in_statement176); - deleteStatement3 = deleteStatement(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, deleteStatement3.Tree); - - } - break; - case 4 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:41:58: insertStatement - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_insertStatement_in_statement180); - insertStatement4 = insertStatement(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, insertStatement4.Tree); - - } - break; - - } - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "statement" - - public class selectStatement_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "selectStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:44:1: selectStatement : query ; - public HqlSqlWalker.selectStatement_return selectStatement() // throws RecognitionException [1] - { - HqlSqlWalker.selectStatement_return retval = new HqlSqlWalker.selectStatement_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - HqlSqlWalker.query_return query5 = default(HqlSqlWalker.query_return); - - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:45:2: ( query ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:45:4: query - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_query_in_selectStatement191); - query5 = query(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, query5.Tree); - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "selectStatement" - - public class updateStatement_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "updateStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:51:1: updateStatement : ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ; - public HqlSqlWalker.updateStatement_return updateStatement() // throws RecognitionException [1] - { - HqlSqlWalker.updateStatement_return retval = new HqlSqlWalker.updateStatement_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode u = null; - IASTNode v = null; - HqlSqlWalker.fromClause_return f = default(HqlSqlWalker.fromClause_return); - - HqlSqlWalker.setClause_return s = default(HqlSqlWalker.setClause_return); - - HqlSqlWalker.whereClause_return w = default(HqlSqlWalker.whereClause_return); - - - IASTNode u_tree=null; - IASTNode v_tree=null; - RewriteRuleNodeStream stream_UPDATE = new RewriteRuleNodeStream(adaptor,"token UPDATE"); - RewriteRuleNodeStream stream_VERSIONED = new RewriteRuleNodeStream(adaptor,"token VERSIONED"); - RewriteRuleSubtreeStream stream_whereClause = new RewriteRuleSubtreeStream(adaptor,"rule whereClause"); - RewriteRuleSubtreeStream stream_setClause = new RewriteRuleSubtreeStream(adaptor,"rule setClause"); - RewriteRuleSubtreeStream stream_fromClause = new RewriteRuleSubtreeStream(adaptor,"rule fromClause"); - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:2: ( ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) -> ^( $u $f $s ( $w)? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:4: ^(u= UPDATE (v= VERSIONED )? f= fromClause s= setClause (w= whereClause )? ) - { - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - u=(IASTNode)Match(input,UPDATE,FOLLOW_UPDATE_in_updateStatement215); - stream_UPDATE.Add(u); - - - BeforeStatement( "update", UPDATE ); - - Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:57: (v= VERSIONED )? - int alt2 = 2; - int LA2_0 = input.LA(1); - - if ( (LA2_0 == VERSIONED) ) - { - alt2 = 1; - } - switch (alt2) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:58: v= VERSIONED - { - _last = (IASTNode)input.LT(1); - v=(IASTNode)Match(input,VERSIONED,FOLLOW_VERSIONED_in_updateStatement222); - stream_VERSIONED.Add(v); - - - } - break; - - } - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_fromClause_in_updateStatement228); - f = fromClause(); - state.followingStackPointer--; - - stream_fromClause.Add(f.Tree); - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_setClause_in_updateStatement232); - s = setClause(); - state.followingStackPointer--; - - stream_setClause.Add(s.Tree); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:97: (w= whereClause )? - int alt3 = 2; - int LA3_0 = input.LA(1); - - if ( (LA3_0 == WHERE) ) - { - alt3 = 1; - } - switch (alt3) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:58:98: w= whereClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_whereClause_in_updateStatement237); - w = whereClause(); - state.followingStackPointer--; - - stream_whereClause.Add(w.Tree); - - } - break; - - } - - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - - // AST REWRITE - // elements: u, f, s, w - // token labels: u - // rule labels: w, f, retval, s - // token list labels: - // rule list labels: - // wildcard labels: - retval.Tree = root_0; - RewriteRuleNodeStream stream_u = new RewriteRuleNodeStream(adaptor, "token u", u); - RewriteRuleSubtreeStream stream_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.Tree : null); - RewriteRuleSubtreeStream stream_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.Tree : null); - RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); - RewriteRuleSubtreeStream stream_s = new RewriteRuleSubtreeStream(adaptor, "rule s", s!=null ? s.Tree : null); - - root_0 = (IASTNode)adaptor.GetNilNode(); - // 59:3: -> ^( $u $f $s ( $w)? ) - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:59:6: ^( $u $f $s ( $w)? ) - { - IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); - root_1 = (IASTNode)adaptor.BecomeRoot(stream_u.NextNode(), root_1); - - adaptor.AddChild(root_1, stream_f.NextTree()); - adaptor.AddChild(root_1, stream_s.NextTree()); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:59:17: ( $w)? - if ( stream_w.HasNext() ) - { - adaptor.AddChild(root_1, stream_w.NextTree()); - - } - stream_w.Reset(); - - adaptor.AddChild(root_0, root_1); - } - - } - - retval.Tree = root_0; - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - BeforeStatementCompletion( "update" ); - PrepareVersioned( ((IASTNode)retval.Tree), v ); - PostProcessUpdate( ((IASTNode)retval.Tree) ); - AfterStatementCompletion( "update" ); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "updateStatement" - - public class deleteStatement_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "deleteStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:62:1: deleteStatement : ^( DELETE fromClause ( whereClause )? ) ; - public HqlSqlWalker.deleteStatement_return deleteStatement() // throws RecognitionException [1] - { - HqlSqlWalker.deleteStatement_return retval = new HqlSqlWalker.deleteStatement_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode DELETE6 = null; - HqlSqlWalker.fromClause_return fromClause7 = default(HqlSqlWalker.fromClause_return); - - HqlSqlWalker.whereClause_return whereClause8 = default(HqlSqlWalker.whereClause_return); - - - IASTNode DELETE6_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:68:2: ( ^( DELETE fromClause ( whereClause )? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:68:4: ^( DELETE fromClause ( whereClause )? ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - DELETE6=(IASTNode)Match(input,DELETE,FOLLOW_DELETE_in_deleteStatement280); - DELETE6_tree = (IASTNode)adaptor.DupNode(DELETE6); - - root_1 = (IASTNode)adaptor.BecomeRoot(DELETE6_tree, root_1); - - - BeforeStatement( "delete", DELETE ); - - Match(input, Token.DOWN, null); - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_fromClause_in_deleteStatement284); - fromClause7 = fromClause(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, fromClause7.Tree); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:68:66: ( whereClause )? - int alt4 = 2; - int LA4_0 = input.LA(1); - - if ( (LA4_0 == WHERE) ) - { - alt4 = 1; - } - switch (alt4) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:68:67: whereClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_whereClause_in_deleteStatement287); - whereClause8 = whereClause(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, whereClause8.Tree); - - } - break; - - } - - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - BeforeStatementCompletion( "delete" ); - PostProcessDelete( ((IASTNode)retval.Tree) ); - AfterStatementCompletion( "delete" ); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "deleteStatement" - - public class insertStatement_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "insertStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:71:1: insertStatement : ^( INSERT intoClause query ) ; - public HqlSqlWalker.insertStatement_return insertStatement() // throws RecognitionException [1] - { - HqlSqlWalker.insertStatement_return retval = new HqlSqlWalker.insertStatement_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode INSERT9 = null; - HqlSqlWalker.intoClause_return intoClause10 = default(HqlSqlWalker.intoClause_return); - - HqlSqlWalker.query_return query11 = default(HqlSqlWalker.query_return); - - - IASTNode INSERT9_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:80:2: ( ^( INSERT intoClause query ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:80:4: ^( INSERT intoClause query ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - INSERT9=(IASTNode)Match(input,INSERT,FOLLOW_INSERT_in_insertStatement317); - INSERT9_tree = (IASTNode)adaptor.DupNode(INSERT9); - - root_1 = (IASTNode)adaptor.BecomeRoot(INSERT9_tree, root_1); - - - BeforeStatement( "insert", INSERT ); - - Match(input, Token.DOWN, null); - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_intoClause_in_insertStatement321); - intoClause10 = intoClause(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, intoClause10.Tree); - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_query_in_insertStatement323); - query11 = query(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, query11.Tree); - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - BeforeStatementCompletion( "insert" ); - PostProcessInsert( ((IASTNode)retval.Tree) ); - AfterStatementCompletion( "insert" ); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "insertStatement" - - public class intoClause_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "intoClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:83:1: intoClause : ^( INTO (p= path ) ps= insertablePropertySpec ) ; - public HqlSqlWalker.intoClause_return intoClause() // throws RecognitionException [1] - { - HqlSqlWalker.intoClause_return retval = new HqlSqlWalker.intoClause_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode INTO12 = null; - HqlSqlWalker.path_return p = default(HqlSqlWalker.path_return); - - HqlSqlWalker.insertablePropertySpec_return ps = default(HqlSqlWalker.insertablePropertySpec_return); - - - IASTNode INTO12_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:87:2: ( ^( INTO (p= path ) ps= insertablePropertySpec ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:87:4: ^( INTO (p= path ) ps= insertablePropertySpec ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - INTO12=(IASTNode)Match(input,INTO,FOLLOW_INTO_in_intoClause347); - INTO12_tree = (IASTNode)adaptor.DupNode(INTO12); - - root_1 = (IASTNode)adaptor.BecomeRoot(INTO12_tree, root_1); - - - HandleClauseStart( INTO ); - - Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:87:43: (p= path ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:87:44: p= path - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_path_in_intoClause354); - p = path(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, p.Tree); - - } - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_insertablePropertySpec_in_intoClause359); - ps = insertablePropertySpec(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, ps.Tree); - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - retval.Tree = CreateIntoClause(((p != null) ? p.p : default(String)), ((ps != null) ? ((IASTNode)ps.Tree) : null)); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "intoClause" - - public class insertablePropertySpec_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "insertablePropertySpec" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:90:1: insertablePropertySpec : ^( RANGE ( IDENT )+ ) ; - public HqlSqlWalker.insertablePropertySpec_return insertablePropertySpec() // throws RecognitionException [1] - { - HqlSqlWalker.insertablePropertySpec_return retval = new HqlSqlWalker.insertablePropertySpec_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode RANGE13 = null; - IASTNode IDENT14 = null; - - IASTNode RANGE13_tree=null; - IASTNode IDENT14_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:91:2: ( ^( RANGE ( IDENT )+ ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:91:4: ^( RANGE ( IDENT )+ ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - RANGE13=(IASTNode)Match(input,RANGE,FOLLOW_RANGE_in_insertablePropertySpec375); - RANGE13_tree = (IASTNode)adaptor.DupNode(RANGE13); - - root_1 = (IASTNode)adaptor.BecomeRoot(RANGE13_tree, root_1); - - - - Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:91:13: ( IDENT )+ - int cnt5 = 0; - do - { - int alt5 = 2; - int LA5_0 = input.LA(1); - - if ( (LA5_0 == IDENT) ) - { - alt5 = 1; - } - - - switch (alt5) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:91:14: IDENT - { - _last = (IASTNode)input.LT(1); - IDENT14=(IASTNode)Match(input,IDENT,FOLLOW_IDENT_in_insertablePropertySpec378); - IDENT14_tree = (IASTNode)adaptor.DupNode(IDENT14); - - adaptor.AddChild(root_1, IDENT14_tree); - - - } - break; - - default: - if ( cnt5 >= 1 ) goto loop5; - EarlyExitException eee5 = - new EarlyExitException(5, input); - throw eee5; - } - cnt5++; - } while (true); - - loop5: - ; // Stops C# compiler whinging that label 'loop5' has no statements - - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "insertablePropertySpec" - - public class setClause_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "setClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:94:1: setClause : ^( SET ( assignment )* ) ; - public HqlSqlWalker.setClause_return setClause() // throws RecognitionException [1] - { - HqlSqlWalker.setClause_return retval = new HqlSqlWalker.setClause_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode SET15 = null; - HqlSqlWalker.assignment_return assignment16 = default(HqlSqlWalker.assignment_return); - - - IASTNode SET15_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:2: ( ^( SET ( assignment )* ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:4: ^( SET ( assignment )* ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - SET15=(IASTNode)Match(input,SET,FOLLOW_SET_in_setClause395); - SET15_tree = (IASTNode)adaptor.DupNode(SET15); - - root_1 = (IASTNode)adaptor.BecomeRoot(SET15_tree, root_1); - - - HandleClauseStart( SET ); - - if ( input.LA(1) == Token.DOWN ) - { - Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:41: ( assignment )* - do - { - int alt6 = 2; - int LA6_0 = input.LA(1); - - if ( (LA6_0 == EQ) ) - { - alt6 = 1; - } - - - switch (alt6) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:42: assignment - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_assignment_in_setClause400); - assignment16 = assignment(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, assignment16.Tree); - - } - break; - - default: - goto loop6; - } - } while (true); - - loop6: - ; // Stops C# compiler whining that label 'loop6' has no statements - - - Match(input, Token.UP, null); - }adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "setClause" - - public class assignment_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "assignment" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:98:1: assignment : ^( EQ (p= propertyRef ) ( newValue ) ) ; - public HqlSqlWalker.assignment_return assignment() // throws RecognitionException [1] - { - HqlSqlWalker.assignment_return retval = new HqlSqlWalker.assignment_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode EQ17 = null; - HqlSqlWalker.propertyRef_return p = default(HqlSqlWalker.propertyRef_return); - - HqlSqlWalker.newValue_return newValue18 = default(HqlSqlWalker.newValue_return); - - - IASTNode EQ17_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:2: ( ^( EQ (p= propertyRef ) ( newValue ) ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:4: ^( EQ (p= propertyRef ) ( newValue ) ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - EQ17=(IASTNode)Match(input,EQ,FOLLOW_EQ_in_assignment427); - EQ17_tree = (IASTNode)adaptor.DupNode(EQ17); - - root_1 = (IASTNode)adaptor.BecomeRoot(EQ17_tree, root_1); - - - - Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:10: (p= propertyRef ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:11: p= propertyRef - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_propertyRef_in_assignment432); - p = propertyRef(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, p.Tree); - - } - - Resolve(((p != null) ? ((IASTNode)p.Tree) : null)); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:48: ( newValue ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:104:49: newValue - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_newValue_in_assignment438); - newValue18 = newValue(); - state.followingStackPointer--; - - adaptor.AddChild(root_1, newValue18.Tree); - - } - - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - EvaluateAssignment( ((IASTNode)retval.Tree) ); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "assignment" - - public class newValue_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "newValue" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:108:1: newValue : ( expr | query ); - public HqlSqlWalker.newValue_return newValue() // throws RecognitionException [1] - { - HqlSqlWalker.newValue_return retval = new HqlSqlWalker.newValue_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - HqlSqlWalker.expr_return expr19 = default(HqlSqlWalker.expr_return); - - HqlSqlWalker.query_return query20 = default(HqlSqlWalker.query_return); - - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:109:2: ( expr | query ) - int alt7 = 2; - int LA7_0 = input.LA(1); - - if ( (LA7_0 == COUNT || LA7_0 == DOT || LA7_0 == FALSE || LA7_0 == NULL || LA7_0 == TRUE || LA7_0 == CASE || LA7_0 == AGGREGATE || LA7_0 == CASE2 || LA7_0 == INDEX_OP || LA7_0 == METHOD_CALL || LA7_0 == UNARY_MINUS || (LA7_0 >= VECTOR_EXPR && LA7_0 <= WEIRD_IDENT) || (LA7_0 >= NUM_INT && LA7_0 <= JAVA_CONSTANT) || (LA7_0 >= PLUS && LA7_0 <= DIV) || (LA7_0 >= COLON && LA7_0 <= IDENT)) ) - { - alt7 = 1; - } - else if ( (LA7_0 == QUERY) ) - { - alt7 = 2; - } - else - { - NoViableAltException nvae_d7s0 = - new NoViableAltException("", 7, 0, input); - - throw nvae_d7s0; - } - switch (alt7) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:109:4: expr - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_expr_in_newValue454); - expr19 = expr(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, expr19.Tree); - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:109:11: query - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_query_in_newValue458); - query20 = query(); - state.followingStackPointer--; - - adaptor.AddChild(root_0, query20.Tree); - - } - break; - - } - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "newValue" - - public class query_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "query" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:114:1: query : ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ; - public HqlSqlWalker.query_return query() // throws RecognitionException [1] - { - HqlSqlWalker.query_return retval = new HqlSqlWalker.query_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode QUERY21 = null; - IASTNode SELECT_FROM22 = null; - HqlSqlWalker.fromClause_return f = default(HqlSqlWalker.fromClause_return); - - HqlSqlWalker.selectClause_return s = default(HqlSqlWalker.selectClause_return); - - HqlSqlWalker.whereClause_return w = default(HqlSqlWalker.whereClause_return); - - HqlSqlWalker.groupClause_return g = default(HqlSqlWalker.groupClause_return); - - HqlSqlWalker.orderClause_return o = default(HqlSqlWalker.orderClause_return); - - - IASTNode QUERY21_tree=null; - IASTNode SELECT_FROM22_tree=null; - RewriteRuleNodeStream stream_SELECT_FROM = new RewriteRuleNodeStream(adaptor,"token SELECT_FROM"); - RewriteRuleNodeStream stream_QUERY = new RewriteRuleNodeStream(adaptor,"token QUERY"); - RewriteRuleSubtreeStream stream_whereClause = new RewriteRuleSubtreeStream(adaptor,"rule whereClause"); - RewriteRuleSubtreeStream stream_orderClause = new RewriteRuleSubtreeStream(adaptor,"rule orderClause"); - RewriteRuleSubtreeStream stream_groupClause = new RewriteRuleSubtreeStream(adaptor,"rule groupClause"); - RewriteRuleSubtreeStream stream_fromClause = new RewriteRuleSubtreeStream(adaptor,"rule fromClause"); - RewriteRuleSubtreeStream stream_selectClause = new RewriteRuleSubtreeStream(adaptor,"rule selectClause"); - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:121:2: ( ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:121:4: ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) - { - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - QUERY21=(IASTNode)Match(input,QUERY,FOLLOW_QUERY_in_query480); - stream_QUERY.Add(QUERY21); - - - BeforeStatement( "select", SELECT ); - - Match(input, Token.DOWN, null); - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_2 = _last; - IASTNode _first_2 = null; - IASTNode root_2 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - SELECT_FROM22=(IASTNode)Match(input,SELECT_FROM,FOLLOW_SELECT_FROM_in_query492); - stream_SELECT_FROM.Add(SELECT_FROM22); - - - - Match(input, Token.DOWN, null); - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_fromClause_in_query500); - f = fromClause(); - state.followingStackPointer--; - - stream_fromClause.Add(f.Tree); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:125:5: (s= selectClause )? - int alt8 = 2; - int LA8_0 = input.LA(1); - - if ( (LA8_0 == SELECT) ) - { - alt8 = 1; - } - switch (alt8) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:125:6: s= selectClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectClause_in_query509); - s = selectClause(); - state.followingStackPointer--; - - stream_selectClause.Add(s.Tree); - - } - break; - - } - - - Match(input, Token.UP, null); adaptor.AddChild(root_1, root_2);_last = _save_last_2; - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:4: (w= whereClause )? - int alt9 = 2; - int LA9_0 = input.LA(1); - - if ( (LA9_0 == WHERE) ) - { - alt9 = 1; - } - switch (alt9) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:5: w= whereClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_whereClause_in_query524); - w = whereClause(); - state.followingStackPointer--; - - stream_whereClause.Add(w.Tree); - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:4: (g= groupClause )? - int alt10 = 2; - int LA10_0 = input.LA(1); - - if ( (LA10_0 == GROUP) ) - { - alt10 = 1; - } - switch (alt10) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:5: g= groupClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_groupClause_in_query534); - g = groupClause(); - state.followingStackPointer--; - - stream_groupClause.Add(g.Tree); - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:129:4: (o= orderClause )? - int alt11 = 2; - int LA11_0 = input.LA(1); - - if ( (LA11_0 == ORDER) ) - { - alt11 = 1; - } - switch (alt11) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:129:5: o= orderClause - { - _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_orderClause_in_query544); - o = orderClause(); - state.followingStackPointer--; - - stream_orderClause.Add(o.Tree); - - } - break; - - } - - - Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1; - } - - - - // AST REWRITE - // elements: s, o, w, f, g - // token labels: - // rule labels: f, w, g, retval, s, o - // token list labels: - // rule list labels: - // wildcard labels: - retval.Tree = root_0; - RewriteRuleSubtreeStream stream_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.Tree : null); - RewriteRuleSubtreeStream stream_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.Tree : null); - RewriteRuleSubtreeStream stream_g = new RewriteRuleSubtreeStream(adaptor, "rule g", g!=null ? g.Tree : null); - RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); - RewriteRuleSubtreeStream stream_s = new RewriteRuleSubtreeStream(adaptor, "rule s", s!=null ? s.Tree : null); - RewriteRuleSubtreeStream stream_o = new RewriteRuleSubtreeStream(adaptor, "rule o", o!=null ? o.Tree : null); - - root_0 = (IASTNode)adaptor.GetNilNode(); - // 131:2: -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:131:5: ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) - { - IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); - root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(SELECT, "SELECT"), root_1); - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:131:14: ( $s)? - if ( stream_s.HasNext() ) - { - adaptor.AddChild(root_1, stream_s.NextTree()); - - } - stream_s.Reset(); - adaptor.AddChild(root_1, stream_f.NextTree()); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:131:21: ( $w)? - if ( stream_w.HasNext() ) - { - adaptor.AddChild(root_1, stream_w.NextTree()); - - } - stream_w.Reset(); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:131:25: ( $g)? - if ( stream_g.HasNext() ) - { - adaptor.AddChild(root_1, stream_g.NextTree()); - - } - stream_g.Reset(); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:131:29: ( $o)? - if ( stream_o.HasNext() ) - { - adaptor.AddChild(root_1, stream_o.NextTree()); - - } - stream_o.Reset(); - - adaptor.AddChild(root_0, root_1); - } - - } - - retval.Tree = root_0; - } - - retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0); - - - // Antlr note: #x_in refers to the input AST, #x refers to the output AST - BeforeStatementCompletion( "select" ); - ProcessQuery( ((s != null) ? ((IASTNode)s.Tree) : null), ((IASTNode)retval.Tree) ); - AfterStatementCompletion( "select" ); - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "query" - - public class orderClause_return : TreeRuleReturnScope - { - private IASTNode tree; - override public object Tree - { - get { return tree; } - set { tree = (IASTNode) value; } - } - }; - - // $ANTLR start "orderClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:134:1: orderClause : ^( ORDER orderExprs ) ; - public HqlSqlWalker.orderClause_return orderClause() // throws RecognitionException [1] - { - HqlSqlWalker.orderClause_return retval = new HqlSqlWalker.orderClause_return(); - retval.Start = input.LT(1); - - IASTNode root_0 = null; - - IASTNode _first_0 = null; - IASTNode _last = null; - - IASTNode ORDER23 = null; - HqlSqlWalker.orderExprs_return orderExprs24 = default(HqlSqlWalker.orderExprs_return); - - - IASTNode ORDER23_tree=null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:135:2: ( ^( ORDER orderExprs ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:135:4: ^( ORDER orderExprs ) - { - root_0 = (IASTNode)adaptor.GetNilNode(); - - _last = (IASTNode)input.LT(1); - { - IASTNode _save_last_1 = _last; - IASTNode _first_1 = null; - IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - ORDER23=(IASTNode)Match(input,ORDER,FOLLOW_ORDER_in_orderClause589); - ORDER23_tree = (IASTNode)adaptor.DupNode(ORDER23); - - root_1 = (IASTNode)... [truncated message content] |
From: <ste...@us...> - 2009-05-08 12:01:53
|
Revision: 4267 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4267&view=rev Author: steverstrong Date: 2009-05-08 12:01:51 +0000 (Fri, 08 May 2009) Log Message: ----------- Fix for test Legacy.MasterDetailTest.MasterDetail Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-08 06:07:00 UTC (rev 4266) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-08 12:01:51 UTC (rev 4267) @@ -12,27 +12,82 @@ public HqlSqlWalkerTreeNodeStream(ITreeAdaptor adaptor, object tree, int initialBufferSize) : base(adaptor, tree, initialBufferSize) {} + /// <summary> + /// Insert a new node into both the Tree and the Node Array. Add DOWN & UP nodes if needed + /// </summary> + /// <param name="parent">The parent node</param> + /// <param name="child">The child node</param> public void InsertChild(IASTNode parent, IASTNode child) { - // Adding a child to the current node. If currently no children, then also need to insert Down & Up nodes - bool needUp = false; - int insertPoint = nodes.IndexOf(parent) + parent.ChildCount + 1; + if (child.ChildCount > 0) + { + throw new InvalidOperationException("Currently do not support adding nodes with children"); + } - if (parent.ChildCount == 0) + int parentIndex = nodes.IndexOf(parent); + int numberOfChildNodes = NumberOfChildNodes(parentIndex); + int insertPoint; + + if (numberOfChildNodes == 0) { + insertPoint = parentIndex + 1; // We want to insert immediately after the parent nodes.Insert(insertPoint, down); - needUp = true; + insertPoint++; // We've just added a new node } - insertPoint++; // We either just inserted a Down node, or one existed already which we need to count + else + { + insertPoint = parentIndex + numberOfChildNodes; + } parent.AddChild(child); nodes.Insert(insertPoint, child); insertPoint++; - if (needUp) + if (numberOfChildNodes == 0) { nodes.Insert(insertPoint, up); } } + + /// <summary> + /// Count the number of child nodes (including DOWNs & UPs) of a parent node + /// </summary> + /// <param name="parentIndex">The index of the parent in the node array</param> + /// <returns>The number of child nodes</returns> + int NumberOfChildNodes(int parentIndex) + { + if (nodes.Count -1 == parentIndex) + { + // We are at the end + return 0; + } + else if (nodes[parentIndex + 1] != down) + { + // Next node is not a DOWN node, so we have no children + return 0; + } + else + { + // Count the DOWNs & UPs + int downCount = 0; + int index = 1; + do + { + if (nodes[parentIndex + index] == down) + { + downCount++; + } + else if (nodes[parentIndex + index] == up) + { + downCount--; + } + + index++; + + } while (downCount > 0); + + return index - 1; + } + } } } \ 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: <aye...@us...> - 2009-05-08 06:07:06
|
Revision: 4266 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4266&view=rev Author: ayenderahien Date: 2009-05-08 06:07:00 +0000 (Fri, 08 May 2009) Log Message: ----------- whitespace & formatting change - spaces to tabs Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -209,13 +209,13 @@ IInterceptor Interceptor { get; } /// <summary> Retrieves the configured event listeners from this event source. </summary> - EventListeners Listeners { get;} + EventListeners Listeners { get; } - int DontFlushFromFind { get;} + int DontFlushFromFind { get; } - ConnectionManager ConnectionManager { get;} + ConnectionManager ConnectionManager { get; } - bool IsEventSource { get;} + bool IsEventSource { get; } /// <summary> /// Get the entity instance associated with the given <tt>Key</tt>, @@ -224,9 +224,9 @@ object GetEntityUsingInterceptor(EntityKey key); /// <summary> Get the persistence context for this session</summary> - IPersistenceContext PersistenceContext { get;} + IPersistenceContext PersistenceContext { get; } - CacheMode CacheMode { get;set;} + CacheMode CacheMode { get; set; } /// <summary> /// Is the <c>ISession</c> still open? @@ -240,7 +240,7 @@ FlushMode FlushMode { get; set; } - string FetchProfile { get;set;} + string FetchProfile { get; set; } /// <summary> The best guess entity name for an entity not in an association</summary> string BestGuessEntityName(object entity); @@ -259,7 +259,7 @@ /// </summary> /// <returns> True if the session is closed; false otherwise. /// </returns> - bool IsClosed { get;} + bool IsClosed { get; } void Flush(); @@ -267,7 +267,7 @@ /// Does this <tt>Session</tt> have an active Hibernate transaction /// or is there a JTA transaction in progress? /// </summary> - bool TransactionInProgress { get;} + bool TransactionInProgress { get; } /// <summary> /// Allow to get the ISession instance without having to @@ -277,7 +277,7 @@ ISession GetSession(); /// <summary> Retrieve the entity mode in effect for this session. </summary> - EntityMode EntityMode { get;} + EntityMode EntityMode { get; } /// <summary> Execute a native SQL update or delete query</summary> int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters); @@ -285,10 +285,10 @@ /// <summary> Execute a HQL update or delete query</summary> int ExecuteUpdate(string query, QueryParameters queryParameters); - FutureCriteriaBatch FutureCriteriaBatch { get; } + FutureCriteriaBatch FutureCriteriaBatch { get; } - FutureQueryBatch FutureQueryBatch { get; } + FutureQueryBatch FutureQueryBatch { get; } - Guid SessionId { get; } + Guid SessionId { get; } } } Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -26,18 +26,18 @@ [NonSerialized] private ISessionFactoryImplementor factory; - protected readonly Guid sessionId = Guid.NewGuid(); + protected readonly Guid sessionId = Guid.NewGuid(); private bool closed; private System.Transactions.Transaction ambientTransation; private bool isAlreadyDisposed; protected bool shouldCloseSessionOnDtcTransactionCompleted; - private static readonly ILog logger = LogManager.GetLogger(typeof (AbstractSessionImpl)); + private static readonly ILog logger = LogManager.GetLogger(typeof(AbstractSessionImpl)); - public Guid SessionId - { - get { return sessionId; } - } + public Guid SessionId + { + get { return sessionId; } + } protected bool TakingPartInDtcTransaction { @@ -58,10 +58,10 @@ public void Initialize() { - using(new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + } } public abstract void InitializeCollection(IPersistentCollection collection, bool writing); @@ -108,20 +108,20 @@ public virtual IQuery GetNamedSQLQuery(string name) { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name); - if (nsqlqd == null) - { - throw new MappingException("Named SQL query not known: " + name); - } - IQuery query = new SqlQueryImpl(nsqlqd, this, - factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); - query.SetComment("named native SQL query " + name); - InitQuery(query, nsqlqd); - return query; - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name); + if (nsqlqd == null) + { + throw new MappingException("Named SQL query not known: " + name); + } + IQuery query = new SqlQueryImpl(nsqlqd, this, + factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); + query.SetComment("named native SQL query " + name); + InitQuery(query, nsqlqd); + return query; + } } public abstract IQueryTranslator[] GetQueries(string query, bool scalar); @@ -147,33 +147,33 @@ public virtual IQuery GetNamedQuery(string queryName) { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - NamedQueryDefinition nqd = factory.GetNamedQuery(queryName); - IQuery query; - if (nqd != null) - { - string queryString = nqd.QueryString; - query = new QueryImpl(queryString, nqd.FlushMode, this, - GetHQLQueryPlan(queryString, false).ParameterMetadata); - query.SetComment("named HQL query " + queryName); - } - else - { - NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName); - if (nsqlqd == null) - { - throw new MappingException("Named query not known: " + queryName); - } - query = new SqlQueryImpl(nsqlqd, this, - factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); - query.SetComment("named native SQL query " + queryName); - nqd = nsqlqd; - } - InitQuery(query, nqd); - return query; - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + NamedQueryDefinition nqd = factory.GetNamedQuery(queryName); + IQuery query; + if (nqd != null) + { + string queryString = nqd.QueryString; + query = new QueryImpl(queryString, nqd.FlushMode, this, + GetHQLQueryPlan(queryString, false).ParameterMetadata); + query.SetComment("named HQL query " + queryName); + } + else + { + NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName); + if (nsqlqd == null) + { + throw new MappingException("Named query not known: " + queryName); + } + query = new SqlQueryImpl(nsqlqd, this, + factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); + query.SetComment("named native SQL query " + queryName); + nqd = nsqlqd; + } + InitQuery(query, nqd); + return query; + } } public bool IsClosed @@ -183,11 +183,11 @@ protected internal virtual void CheckAndUpdateSessionStatus() { - using (new SessionIdLoggingContext(sessionId)) - { - ErrorIfClosed(); - EnlistInAmbientTransactionIfNeeded(); - } + using (new SessionIdLoggingContext(sessionId)) + { + ErrorIfClosed(); + EnlistInAmbientTransactionIfNeeded(); + } } protected internal virtual void ErrorIfClosed() @@ -212,186 +212,186 @@ protected internal void SetClosed() { - try - { - if (ambientTransation != null) - ambientTransation.Dispose(); - } - catch (Exception) - { - //ignore - } + try + { + if (ambientTransation != null) + ambientTransation.Dispose(); + } + catch (Exception) + { + //ignore + } closed = true; } private void InitQuery(IQuery query, NamedQueryDefinition nqd) { - using (new SessionIdLoggingContext(sessionId)) - { - query.SetCacheable(nqd.IsCacheable); - query.SetCacheRegion(nqd.CacheRegion); - if (nqd.Timeout != -1) - { - query.SetTimeout(nqd.Timeout); - } - if (nqd.FetchSize != -1) - { - query.SetFetchSize(nqd.FetchSize); - } - if (nqd.CacheMode.HasValue) - query.SetCacheMode(nqd.CacheMode.Value); + using (new SessionIdLoggingContext(sessionId)) + { + query.SetCacheable(nqd.IsCacheable); + query.SetCacheRegion(nqd.CacheRegion); + if (nqd.Timeout != -1) + { + query.SetTimeout(nqd.Timeout); + } + if (nqd.FetchSize != -1) + { + query.SetFetchSize(nqd.FetchSize); + } + if (nqd.CacheMode.HasValue) + query.SetCacheMode(nqd.CacheMode.Value); - query.SetReadOnly(nqd.IsReadOnly); - if (nqd.Comment != null) - { - query.SetComment(nqd.Comment); - } - query.SetFlushMode(nqd.FlushMode); - } + query.SetReadOnly(nqd.IsReadOnly); + if (nqd.Comment != null) + { + query.SetComment(nqd.Comment); + } + query.SetFlushMode(nqd.FlushMode); + } } public virtual IQuery CreateQuery(string queryString) { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata); - query.SetComment(queryString); - return query; - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata); + query.SetComment(queryString); + return query; + } } public virtual ISQLQuery CreateSQLQuery(string sql) { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql)); - query.SetComment("dynamic native SQL query"); - return query; - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql)); + query.SetComment("dynamic native SQL query"); + return query; + } } protected internal virtual HQLQueryPlan GetHQLQueryPlan(string query, bool shallow) { - using (new SessionIdLoggingContext(sessionId)) - { - return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters); - } + using (new SessionIdLoggingContext(sessionId)) + { + return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters); + } } protected internal virtual NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec) { - using (new SessionIdLoggingContext(sessionId)) - { - return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec); - } + using (new SessionIdLoggingContext(sessionId)) + { + return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec); + } } protected ADOException Convert(Exception sqlException, string message) { - using (new SessionIdLoggingContext(sessionId)) - { - return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message); - } + using (new SessionIdLoggingContext(sessionId)) + { + return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message); + } } protected void AfterOperation(bool success) { - using (new SessionIdLoggingContext(sessionId)) - { - if (!ConnectionManager.IsInActiveTransaction) - { - ConnectionManager.AfterNonTransactionalQuery(success); - } - } + using (new SessionIdLoggingContext(sessionId)) + { + if (!ConnectionManager.IsInActiveTransaction) + { + ConnectionManager.AfterNonTransactionalQuery(success); + } + } } #region IEnlistmentNotification Members void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) { - using (new SessionIdLoggingContext(sessionId)) - { - try - { - using (var tx = new TransactionScope(ambientTransation)) - { - BeforeTransactionCompletion(null); - if (FlushMode != FlushMode.Never) - { - using (ConnectionManager.FlushingFromDtcTransaction) - Flush(); - } - logger.Debug("prepared for DTC transaction"); + using (new SessionIdLoggingContext(sessionId)) + { + try + { + using (var tx = new TransactionScope(ambientTransation)) + { + BeforeTransactionCompletion(null); + if (FlushMode != FlushMode.Never) + { + using (ConnectionManager.FlushingFromDtcTransaction) + Flush(); + } + logger.Debug("prepared for DTC transaction"); - tx.Complete(); - } - preparingEnlistment.Prepared(); - } - catch (Exception exception) - { - logger.Error("DTC transaction prepre phase failed", exception); - preparingEnlistment.ForceRollback(exception); + tx.Complete(); + } + preparingEnlistment.Prepared(); + } + catch (Exception exception) + { + logger.Error("DTC transaction prepre phase failed", exception); + preparingEnlistment.ForceRollback(exception); - } - } + } + } } void IEnlistmentNotification.Commit(Enlistment enlistment) { - using (new SessionIdLoggingContext(sessionId)) - { - logger.Debug("committing DTC transaction"); - // we have nothing to do here, since it is the actual - // DB connection that will commit the transaction - enlistment.Done(); - } + using (new SessionIdLoggingContext(sessionId)) + { + logger.Debug("committing DTC transaction"); + // we have nothing to do here, since it is the actual + // DB connection that will commit the transaction + enlistment.Done(); + } } void IEnlistmentNotification.Rollback(Enlistment enlistment) { - using (new SessionIdLoggingContext(sessionId)) - { - AfterTransactionCompletion(false, null); - logger.Debug("rolled back DTC transaction"); - enlistment.Done(); - } + using (new SessionIdLoggingContext(sessionId)) + { + AfterTransactionCompletion(false, null); + logger.Debug("rolled back DTC transaction"); + enlistment.Done(); + } } void IEnlistmentNotification.InDoubt(Enlistment enlistment) { - using (new SessionIdLoggingContext(sessionId)) - { - AfterTransactionCompletion(false, null); - logger.Debug("DTC transaction is in doubt"); - enlistment.Done(); - } + using (new SessionIdLoggingContext(sessionId)) + { + AfterTransactionCompletion(false, null); + logger.Debug("DTC transaction is in doubt"); + enlistment.Done(); + } } - protected void EnlistInAmbientTransactionIfNeeded() - { - using (new SessionIdLoggingContext(sessionId)) - { - if (ambientTransation != null) - return; - if (System.Transactions.Transaction.Current == null) - return; - ambientTransation = System.Transactions.Transaction.Current.Clone(); - logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel); - AfterTransactionBegin(null); - ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) - { - bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed; - AfterTransactionCompletion(wasSuccessful, null); - if (shouldCloseSessionOnDtcTransactionCompleted) - Dispose(true); - }; - ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); - } - } + protected void EnlistInAmbientTransactionIfNeeded() + { + using (new SessionIdLoggingContext(sessionId)) + { + if (ambientTransation != null) + return; + if (System.Transactions.Transaction.Current == null) + return; + ambientTransation = System.Transactions.Transaction.Current.Clone(); + logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel); + AfterTransactionBegin(null); + ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) + { + bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed; + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + Dispose(true); + }; + ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); + } + } - protected abstract void Dispose(bool disposing); + protected abstract void Dispose(bool disposing); #endregion } Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -19,9 +19,9 @@ { public class MultiCriteriaImpl : IMultiCriteria { - private static readonly ILog log = LogManager.GetLogger(typeof(MultiCriteriaImpl)); - private readonly IList<ICriteria> criteriaQueries = new List<ICriteria>(); - private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); + private static readonly ILog log = LogManager.GetLogger(typeof(MultiCriteriaImpl)); + private readonly IList<ICriteria> criteriaQueries = new List<ICriteria>(); + private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); private readonly SessionImpl session; private readonly ISessionFactoryImplementor factory; @@ -65,33 +65,33 @@ public IList List() { - using (new SessionIdLoggingContext(session.SessionId)) - { - bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; + using (new SessionIdLoggingContext(session.SessionId)) + { + bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; - CreateCriteriaLoaders(); - CombineCriteriaQueries(); + CreateCriteriaLoaders(); + CombineCriteriaQueries(); - if (log.IsDebugEnabled) - { - log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count); - for (int i = 0; i < criteriaQueries.Count; i++) - { - log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]); - } - } + if (log.IsDebugEnabled) + { + log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count); + for (int i = 0; i < criteriaQueries.Count; i++) + { + log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]); + } + } - if (cacheable) - { - criteriaResults = ListUsingQueryCache(); - } - else - { - criteriaResults = ListIgnoreQueryCache(); - } + if (cacheable) + { + criteriaResults = ListUsingQueryCache(); + } + else + { + criteriaResults = ListIgnoreQueryCache(); + } - return criteriaResults; - } + return criteriaResults; + } } @@ -156,7 +156,7 @@ for (int i = 0; i < results.Count; i++) { CriteriaImpl critImp = criteriaQueries[i] as CriteriaImpl; - if(critImp==null || critImp.ResultTransformer==null) + if (critImp == null || critImp.ResultTransformer == null) continue; results[i] = critImp.ResultTransformer.TransformList((IList)results[i]); } @@ -207,15 +207,15 @@ hydratedObjects[i] = entitySpan == 0 ? null : new ArrayList(entitySpan); EntityKey[] keys = new EntityKey[entitySpan]; QueryParameters queryParameters = parameters[i]; - IList tmpResults; - if (resultCollectionGenericType[i] == typeof(object)) - { - tmpResults = new ArrayList(); - } - else - { - tmpResults = (IList) Activator.CreateInstance(typeof (List<>).MakeGenericType(resultCollectionGenericType[i])); - } + IList tmpResults; + if (resultCollectionGenericType[i] == typeof(object)) + { + tmpResults = new ArrayList(); + } + else + { + tmpResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i])); + } RowSelection selection = parameters[i].RowSelection; createSubselects[i] = loader.IsSubselectLoadingEnabled; @@ -341,7 +341,7 @@ } return colIndex; } - + public IMultiCriteria Add(System.Type resultGenericListType, ICriteria criteria) { criteriaQueries.Add(criteria); @@ -350,64 +350,64 @@ return this; } - public IMultiCriteria Add(ICriteria criteria) + public IMultiCriteria Add(ICriteria criteria) { - return Add<object>(criteria); + return Add<object>(criteria); } - public IMultiCriteria Add(string key, ICriteria criteria) + public IMultiCriteria Add(string key, ICriteria criteria) { - return Add<object>(key, criteria); + return Add<object>(key, criteria); } - public IMultiCriteria Add(DetachedCriteria detachedCriteria) - { - return Add<object>(detachedCriteria); - } + public IMultiCriteria Add(DetachedCriteria detachedCriteria) + { + return Add<object>(detachedCriteria); + } - public IMultiCriteria Add(string key, DetachedCriteria detachedCriteria) - { - return Add<object>(key, detachedCriteria); - } + public IMultiCriteria Add(string key, DetachedCriteria detachedCriteria) + { + return Add<object>(key, detachedCriteria); + } - public IMultiCriteria Add<T>(ICriteria criteria) + public IMultiCriteria Add<T>(ICriteria criteria) { criteriaQueries.Add(criteria); - resultCollectionGenericType.Add(typeof(T)); + resultCollectionGenericType.Add(typeof(T)); return this; } - public IMultiCriteria Add<T>(string key, ICriteria criteria) + public IMultiCriteria Add<T>(string key, ICriteria criteria) { ThrowIfKeyAlreadyExists(key); criteriaQueries.Add(criteria); criteriaResultPositions.Add(key, criteriaQueries.Count - 1); - resultCollectionGenericType.Add(typeof(T)); + resultCollectionGenericType.Add(typeof(T)); return this; } - public IMultiCriteria Add<T>(DetachedCriteria detachedCriteria) + public IMultiCriteria Add<T>(DetachedCriteria detachedCriteria) { criteriaQueries.Add( detachedCriteria.GetExecutableCriteria(session) ); - resultCollectionGenericType.Add(typeof (T)); + resultCollectionGenericType.Add(typeof(T)); return this; } - - public IMultiCriteria Add<T>(string key, DetachedCriteria detachedCriteria) - { - ThrowIfKeyAlreadyExists(key); - criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session)); - criteriaResultPositions.Add(key, criteriaQueries.Count - 1); - resultCollectionGenericType.Add(typeof(T)); - return this; - } - + public IMultiCriteria Add<T>(string key, DetachedCriteria detachedCriteria) + { + ThrowIfKeyAlreadyExists(key); + criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session)); + criteriaResultPositions.Add(key, criteriaQueries.Count - 1); + resultCollectionGenericType.Add(typeof(T)); + + return this; + } + public IMultiCriteria SetCacheable(bool cachable) { isCacheable = cachable; Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -22,7 +22,7 @@ private static readonly ILog log = LogManager.GetLogger(typeof(MultiQueryImpl)); private readonly List<IQuery> queries = new List<IQuery>(); - private readonly List<IQueryTranslator> translators = new List<IQueryTranslator>(); private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); private readonly List<QueryParameters> parameters = new List<QueryParameters>(); private IList queryResults; + private readonly List<IQueryTranslator> translators = new List<IQueryTranslator>(); private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); private readonly List<QueryParameters> parameters = new List<QueryParameters>(); private IList queryResults; private readonly Dictionary<string, int> criteriaResultPositions = new Dictionary<string, int>(); private string cacheRegion; private int commandTimeout = RowSelection.NoValue; @@ -288,13 +288,13 @@ } return this; } - - public IMultiQuery AddNamedQuery<T>(string key, string namedQuery) - { - ThrowIfKeyAlreadyExists(key); - return Add<T>(key, session.GetNamedQuery(namedQuery)); - } + public IMultiQuery AddNamedQuery<T>(string key, string namedQuery) + { + ThrowIfKeyAlreadyExists(key); + return Add<T>(key, session.GetNamedQuery(namedQuery)); + } + public IMultiQuery Add(System.Type resultGenericListType, IQuery query) { AddQueryForLaterExecutionAndReturnIndexOfQuery(resultGenericListType, query); @@ -302,66 +302,66 @@ return this; } - public IMultiQuery Add(string key, IQuery query) - { - return Add<object>(key, query); - } + public IMultiQuery Add(string key, IQuery query) + { + return Add<object>(key, query); + } - public IMultiQuery Add(IQuery query) - { - return Add<object>(query); - } + public IMultiQuery Add(IQuery query) + { + return Add<object>(query); + } - public IMultiQuery Add(string key, string hql) - { - return Add<object>(key, hql); - } + public IMultiQuery Add(string key, string hql) + { + return Add<object>(key, hql); + } - public IMultiQuery Add(string hql) - { - return Add<object>(hql); - } + public IMultiQuery Add(string hql) + { + return Add<object>(hql); + } - public IMultiQuery AddNamedQuery(string namedQuery) - { - return AddNamedQuery<object>(namedQuery); - } + public IMultiQuery AddNamedQuery(string namedQuery) + { + return AddNamedQuery<object>(namedQuery); + } - public IMultiQuery AddNamedQuery(string key, string namedQuery) - { - return AddNamedQuery<object>(key, namedQuery); - } + public IMultiQuery AddNamedQuery(string key, string namedQuery) + { + return AddNamedQuery<object>(key, namedQuery); + } public IMultiQuery Add<T>(IQuery query) - { - AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query); - return this; - } + { + AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query); + return this; + } - public IMultiQuery Add<T>(string key, IQuery query) - { - ThrowIfKeyAlreadyExists(key); + public IMultiQuery Add<T>(string key, IQuery query) + { + ThrowIfKeyAlreadyExists(key); criteriaResultPositions.Add(key, AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query)); - return this; - } + return this; + } - public IMultiQuery Add<T>(string hql) - { - return Add<T>(((ISession)session).CreateQuery(hql)); - } + public IMultiQuery Add<T>(string hql) + { + return Add<T>(((ISession)session).CreateQuery(hql)); + } - public IMultiQuery Add<T>(string key, string hql) - { - ThrowIfKeyAlreadyExists(key); - return Add<T>(key, ((ISession)session).CreateQuery(hql)); - } + public IMultiQuery Add<T>(string key, string hql) + { + ThrowIfKeyAlreadyExists(key); + return Add<T>(key, ((ISession)session).CreateQuery(hql)); + } - public IMultiQuery AddNamedQuery<T>(string namedQuery) - { - return Add<T>(session.GetNamedQuery(namedQuery)); - } + public IMultiQuery AddNamedQuery<T>(string namedQuery) + { + return Add<T>(session.GetNamedQuery(namedQuery)); + } - public IMultiQuery SetCacheable(bool cacheable) + public IMultiQuery SetCacheable(bool cacheable) { isCacheable = cacheable; return this; @@ -378,30 +378,30 @@ /// </summary> public IList List() { - using (new SessionIdLoggingContext(session.SessionId)) - { - bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; - combinedParameters = CreateCombinedQueryParameters(); + using (new SessionIdLoggingContext(session.SessionId)) + { + bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; + combinedParameters = CreateCombinedQueryParameters(); - if (log.IsDebugEnabled) - { - log.DebugFormat("Multi query with {0} queries.", queries.Count); - for (int i = 0; i < queries.Count; i++) - { - log.DebugFormat("Query #{0}: {1}", i, queries[i]); - } - } + if (log.IsDebugEnabled) + { + log.DebugFormat("Multi query with {0} queries.", queries.Count); + for (int i = 0; i < queries.Count; i++) + { + log.DebugFormat("Query #{0}: {1}", i, queries[i]); + } + } - try - { - Before(); - return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache(); - } - finally - { - After(); - } - } + try + { + Before(); + return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache(); + } + finally + { + After(); + } + } } public IMultiQuery SetFlushMode(FlushMode mode) @@ -492,15 +492,15 @@ { IQueryTranslator translator = Translators[i]; QueryParameters parameter = Parameters[i]; - IList tempResults; - if (resultCollectionGenericType[i] == typeof(object)) - { - tempResults = new ArrayList(); - } - else - { - tempResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i])); - } + IList tempResults; + if (resultCollectionGenericType[i] == typeof(object)) + { + tempResults = new ArrayList(); + } + else + { + tempResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i])); + } int entitySpan = translator.Loader.EntityPersisters.Length; hydratedObjects[i] = entitySpan > 0 ? new ArrayList() : null; RowSelection selection = parameter.RowSelection; @@ -542,8 +542,8 @@ keys, false); - tempResults.Add(result); - + tempResults.Add(result); + if (createSubselects[i]) { subselectResultKeys[i].Add(keys); @@ -682,7 +682,7 @@ { if (queryResults == null) { - queryResults= List(); + queryResults = List(); } if (!criteriaResultPositions.ContainsKey(key)) Modified: trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -3,49 +3,49 @@ namespace NHibernate.Impl { - public class SessionIdLoggingContext : IDisposable - { - private readonly object oldSessonId; + public class SessionIdLoggingContext : IDisposable + { + private readonly object oldSessonId; - public SessionIdLoggingContext(Guid id) - { - oldSessonId = SessionId; - SessionId = id; - } + public SessionIdLoggingContext(Guid id) + { + oldSessonId = SessionId; + SessionId = id; + } - /// <summary> - /// Error handling in this case will only kick in if we cannot set values on the TLS - /// this is usally the case if we are called from the finalizer, since this is something - /// that we do only for logging, we ignore the error. - /// </summary> - private static object SessionId - { - get - { - try - { - return ThreadContext.Properties["sessionId"]; - } - catch (Exception) - { - return null; - } - } - set - { - try - { - ThreadContext.Properties["sessionId"] = value; - } - catch (Exception) - { - } - } - } + /// <summary> + /// Error handling in this case will only kick in if we cannot set values on the TLS + /// this is usally the case if we are called from the finalizer, since this is something + /// that we do only for logging, we ignore the error. + /// </summary> + private static object SessionId + { + get + { + try + { + return ThreadContext.Properties["sessionId"]; + } + catch (Exception) + { + return null; + } + } + set + { + try + { + ThreadContext.Properties["sessionId"] = value; + } + catch (Exception) + { + } + } + } - public void Dispose() - { - SessionId = oldSessonId; - } - } + public void Dispose() + { + SessionId = oldSessonId; + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 06:07:00 UTC (rev 4266) @@ -42,15 +42,18 @@ private readonly long timestamp; - private CacheMode cacheMode= CacheMode.Normal; + private CacheMode cacheMode = CacheMode.Normal; private FlushMode flushMode = FlushMode.Auto; private readonly IInterceptor interceptor; - [NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco; + [NonSerialized] + private readonly EntityMode entityMode = EntityMode.Poco; - [NonSerialized] private FutureCriteriaBatch futureCriteriaBatch; - [NonSerialized] private FutureQueryBatch futureQueryBatch; + [NonSerialized] + private FutureCriteriaBatch futureCriteriaBatch; + [NonSerialized] + private FutureQueryBatch futureQueryBatch; [NonSerialized] private readonly EventListeners listeners; @@ -63,20 +66,24 @@ [NonSerialized] private int dontFlushFromFind; - [NonSerialized] private readonly IDictionary<string, IFilter> enabledFilters = new Dictionary<string, IFilter>(); + [NonSerialized] + private readonly IDictionary<string, IFilter> enabledFilters = new Dictionary<string, IFilter>(); [NonSerialized] private readonly StatefulPersistenceContext persistenceContext; - + [NonSerialized] private readonly ISession rootSession; [NonSerialized] - private IDictionary<EntityMode,ISession> childSessionsByEntityMode; + private IDictionary<EntityMode, ISession> childSessionsByEntityMode; - [NonSerialized] private readonly bool flushBeforeCompletionEnabled; - [NonSerialized] private readonly bool autoCloseSessionEnabled; - [NonSerialized] private readonly ConnectionReleaseMode connectionReleaseMode; + [NonSerialized] + private readonly bool flushBeforeCompletionEnabled; + [NonSerialized] + private readonly bool autoCloseSessionEnabled; + [NonSerialized] + private readonly ConnectionReleaseMode connectionReleaseMode; #region System.Runtime.Serialization.ISerializable Members @@ -133,7 +140,7 @@ } info.AddValue("factory", Factory, typeof(SessionFactoryImpl)); - info.AddValue("persistenceContext", persistenceContext, typeof (StatefulPersistenceContext)); + info.AddValue("persistenceContext", persistenceContext, typeof(StatefulPersistenceContext)); info.AddValue("actionQueue", actionQueue, typeof(ActionQueue)); info.AddValue("timestamp", timestamp); info.AddValue("flushMode", flushMode); @@ -195,35 +202,35 @@ ConnectionReleaseMode connectionReleaseMode) : base(factory) { - using (new SessionIdLoggingContext(sessionId)) - { - if (interceptor == null) - throw new AssertionFailure("The interceptor can not be null."); + using (new SessionIdLoggingContext(sessionId)) + { + if (interceptor == null) + throw new AssertionFailure("The interceptor can not be null."); - rootSession = null; - this.timestamp = timestamp; - this.entityMode = entityMode; - this.interceptor = interceptor; - listeners = factory.EventListeners; - actionQueue = new ActionQueue(this); - persistenceContext = new StatefulPersistenceContext(this); - this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; - this.autoCloseSessionEnabled = autoCloseSessionEnabled; - this.connectionReleaseMode = connectionReleaseMode; - connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor); + rootSession = null; + this.timestamp = timestamp; + this.entityMode = entityMode; + this.interceptor = interceptor; + listeners = factory.EventListeners; + actionQueue = new ActionQueue(this); + persistenceContext = new StatefulPersistenceContext(this); + this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; + this.autoCloseSessionEnabled = autoCloseSessionEnabled; + this.connectionReleaseMode = connectionReleaseMode; + connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor); - if (factory.Statistics.IsStatisticsEnabled) - { - factory.StatisticsImplementor.OpenSession(); - } + if (factory.Statistics.IsStatisticsEnabled) + { + factory.StatisticsImplementor.OpenSession(); + } - if (log.IsDebugEnabled) - { - log.Debug("opened session at timestamp: " + timestamp); - } + if (log.IsDebugEnabled) + { + log.Debug("opened session at timestamp: " + timestamp); + } - CheckAndUpdateSessionStatus(); - } + CheckAndUpdateSessionStatus(); + } } /// <summary> @@ -232,58 +239,58 @@ /// <param name="parent">The parent Session</param> /// <param name="entityMode">The entity mode</param> private SessionImpl(SessionImpl parent, EntityMode entityMode) - :base (parent.Factory) + : base(parent.Factory) { - using (new SessionIdLoggingContext(sessionId)) - { - rootSession = parent; - timestamp = parent.timestamp; - connectionManager = parent.connectionManager; - interceptor = parent.interceptor; - listeners = parent.listeners; - actionQueue = new ActionQueue(this); - this.entityMode = entityMode; - persistenceContext = new StatefulPersistenceContext(this); - flushBeforeCompletionEnabled = false; - autoCloseSessionEnabled = false; - connectionReleaseMode = parent.ConnectionReleaseMode; // NH different + using (new SessionIdLoggingContext(sessionId)) + { + rootSession = parent; + timestamp = parent.timestamp; + connectionManager = parent.connectionManager; + interceptor = parent.interceptor; + listeners = parent.listeners; + actionQueue = new ActionQueue(this); + this.entityMode = entityMode; + persistenceContext = new StatefulPersistenceContext(this); + flushBeforeCompletionEnabled = false; + autoCloseSessionEnabled = false; + connectionReleaseMode = parent.ConnectionReleaseMode; // NH different - if (Factory.Statistics.IsStatisticsEnabled) - Factory.StatisticsImplementor.OpenSession(); + if (Factory.Statistics.IsStatisticsEnabled) + Factory.StatisticsImplementor.OpenSession(); - log.Debug("opened session [" + entityMode + "]"); + log.Debug("opened session [" + entityMode + "]"); - CheckAndUpdateSessionStatus(); - } + CheckAndUpdateSessionStatus(); + } } - public override FutureCriteriaBatch FutureCriteriaBatch - { - get - { - if (futureCriteriaBatch == null) - futureCriteriaBatch = new FutureCriteriaBatch(this); - return futureCriteriaBatch; - } - internal set - { - futureCriteriaBatch = value; - } - } + public override FutureCriteriaBatch FutureCriteriaBatch + { + get + { + if (futureCriteriaBatch == null) + futureCriteriaBatch = new FutureCriteriaBatch(this); + return futureCriteriaBatch; + } + internal set + { + futureCriteriaBatch = value; + } + } - public override FutureQueryBatch FutureQueryBatch - { - get - { - if (futureQueryBatch == null) - futureQueryBatch = new FutureQueryBatch(this); - return futureQueryBatch; - } - internal set - { - futureQueryBatch = value; - } - } + public override FutureQueryBatch FutureQueryBatch + { + get + { + if (futureQueryBatch == null) + futureQueryBatch = new FutureQueryBatch(this); + return futureQueryBatch; + } + internal set + { + futureQueryBatch = value; + } + } /// <summary></summary> public override IBatcher Batcher @@ -319,47 +326,47 @@ /// <summary></summary> public IDbConnection Close() { - using (new SessionIdLoggingContext(sessionId)) - { - log.Debug("closing session"); - if (IsClosed) - { - throw new SessionException("Session was already closed"); - } + using (new SessionIdLoggingContext(sessionId)) + { + log.Debug("closing session"); + if (IsClosed) + { + throw new SessionException("Session was already closed"); + } - if (Factory.Statistics.IsStatisticsEnabled) - { - Factory.StatisticsImplementor.CloseSession(); - } + if (Factory.Statistics.IsStatisticsEnabled) + { + Factory.StatisticsImplementor.CloseSession(); + } - try - { - try - { - if (childSessionsByEntityMode != null) - { - foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode) - { - pair.Value.Close(); - } - } - } - catch - { - // just ignore - } + try + { + try + { + if (childSessionsByEntityMode != null) + { + foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode) + { + pair.Value.Close(); + } + } + } + catch + { + // just ignore + } - if (rootSession == null) - return connectionManager.Close(); - else - return null; - } - finally - { - SetClosed(); - Cleanup(); - } - } + if (rootSession == null) + return connectionManager.Close(); + else + return null; + } + finally + { + SetClosed(); + Cleanup(); + } + } } /// <summary> @@ -369,74 +376,74 @@ /// </summary> public override void AfterTransactionCompletion(bool success, ITransaction tx) { - using (new SessionIdLoggingContext(sessionId)) - { - log.Debug("transaction completion"); - if (Factory.Statistics.IsStatisticsEnabled) - { - Factory.StatisticsImplementor.EndTransaction(success); - } + using (new SessionIdLoggingContext(sessionId)) + { + log.Debug("transaction completion"); + if (Factory.Statistics.IsStatisticsEnabled) + { + Factory.StatisticsImplementor.EndTransaction(success); + } - connectionManager.AfterTransaction(); - persistenceContext.AfterTransactionCompletion(); - actionQueue.AfterTransactionCompletion(success); - if (rootSession == null) - { - try - { - interceptor.AfterTransactionCompletion(tx); - } - catch (Exception t) - { - log.Error("exception in interceptor afterTransactionCompletion()", t); - } - } + connectionManager.AfterTransaction(); + persistenceContext.AfterTransactionCompletion(); + actionQueue.AfterTransactionCompletion(success); + if (rootSession == null) + { + try + { + interceptor.AfterTransactionCompletion(tx); + } + catch (Exception t) + { + log.Error("exception in interceptor afterTransactionCompletion()", t); + } + } - //if (autoClear) - // Clear(); - } + //if (autoClear) + // Clear(); + } } private void Cleanup() { - using (new SessionIdLoggingContext(sessionId)) - { - persistenceContext.Clear(); - } + using (new SessionIdLoggingContext(sessionId)) + { + persistenceContext.Clear(); + } } public LockMode GetCurrentLockMode(object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); - if (obj == null) - { - throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); - } - if (obj is INHibernateProxy) - { - obj = ((INHibernateProxy) obj).HibernateLazyInitializer.GetImplementation(this); - if (obj == null) - { - return LockMode.None; - } - } + if (obj == null) + { + throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); + } + if (obj is INHibernateProxy) + { + obj = ((INHibernateProxy)obj).HibernateLazyInitializer.GetImplementation(this); + if (obj == null) + { + return LockMode.None; + } + } - EntityEntry e = persistenceContext.GetEntry(obj); - if (e == null) - { - throw new TransientObjectException("Given object not associated with the session"); - } + EntityEntry e = persistenceContext.GetEntry(obj); + if (e == null) + { + throw new TransientObjectException("Given object not associated with the session"); + } - if (e.Status != Status.Loaded) - { - throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName); - } - return e.LockMode; - } + if (e.Status != Status.Loaded) + { + throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName); + } + return e.LockMode; + } } public override bool IsOpen @@ -453,16 +460,16 @@ { using (new SessionIdLoggingContext(sessionId)) { - return FireSave(new SaveOrUpdateEvent(null, obj, this)); + return FireSave(new SaveOrUpdateEvent(null, obj, this)); } } public object Save(string entityName, object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - return FireSave(new SaveOrUpdateEvent(entityName, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + return FireSave(new SaveOrUpdateEvent(entityName, obj, this)); + } } /// <summary> @@ -472,10 +479,10 @@ /// <param name="id"></param> public void Save(object obj, object id) { - using (new SessionIdLoggingContext(sessionId)) - { - FireSave(new SaveOrUpdateEvent(null, obj, id, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireSave(new SaveOrUpdateEvent(null, obj, id, this)); + } } /// <summary> @@ -484,59 +491,59 @@ /// <param name="obj"></param> public void Delete(object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireDelete(new DeleteEvent(obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireDelete(new DeleteEvent(obj, this)); + } } /// <summary> Delete a persistent object (by explicit entity name)</summary> public void Delete(string entityName, object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireDelete(new DeleteEvent(entityName, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireDelete(new DeleteEvent(entityName, obj, this)); + } } public void Update(object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireUpdate(new SaveOrUpdateEvent(null, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(null, obj, this)); + } } public void Update(string entityName, object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireUpdate(new SaveOrUpdateEvent(entityName, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + } } public void SaveOrUpdate(object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this)); + } } public void SaveOrUpdate(string entityName, object obj) { - using (new SessionIdLoggingContext(sessionId)) - { - FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + } } public void Update(object obj, object id) { - using (new SessionIdLoggingContext(sessionId)) - { - FireUpdate(new SaveOrUpdateEvent(null, obj, id, this)); - } + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(null, obj, id, this)); + } } private static readonly object[] NoArgs = new object[0]; @@ -549,219 +556,219 @@ /// <returns></returns> public IList Find(string query) { - using (new SessionIdLoggingContext(sessionId)) - { - return List(query, new QueryParameters()); - } + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters()); + } } public IList Find(string query, object value, IType type) { - using (new SessionIdLoggingContext(sessionId)) - { - return List(query, new QueryParameters(type, value)); - } + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters(type, value)); + } } public IList Find(string query, object[] values, IType[] types) { - using (new SessionIdLoggingContext(sessionId)) - { - return List(query, new QueryParameters(types, values)); - } + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters(types, values)); + } } public override IList List(string query, QueryParameters parameters) { - using (new SessionIdLoggingContext(sessionId)) - { - IList results = new ArrayList(); - List(query, parameters, results); - return results; - } + using (new SessionIdLoggingContext(sessionId)) + { + IList results = new ArrayList(); + List(query, parameters, results); + return results; + } } public override IList<T> List<T>(string query, QueryParameters parameters) { - using (new SessionIdLoggingContext(sessionId)) - { - List<T> results = new List<T>(); - List(query, parameters, results); - return results; - } + using (new SessionIdLoggingContext(sessionId)) + { + List<T> results = new List<T>(); + List(query, parameters, results); + return results; + } } - public override void List(string query, QueryParameters queryParameters, IList results) - { - using (new SessionIdLoggingContext(sessionId)) - { - CheckAndUpdateSessionStatus(); - queryParameters.ValidateParameters(); - HQLQueryPlan plan = GetHQLQueryPlan(query, false); - AutoFlushIfRequired(plan.QuerySpaces); + public override void List(string query, QueryParameters queryParameters, IList results) + { + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + queryParameters.ValidateParameters(); + HQLQueryPlan plan = GetHQLQueryPlan(query, false); + AutoFlushIfRequired(plan.QuerySpaces); - bool success = false; - dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called - try - { - plan.PerformList(queryParameters, this, results); - success = true; - } - catch (HibernateException) - { - // Do not call Convert on HibernateExceptions - throw; - } - catch (Exception e) - { - throw Convert(e, "Could not execute query"); - } - finally - { - dontFlushFromFind--; - AfterOperation(success); - } - } - } + bool success = false; + dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called + try + { + plan.PerformList(queryParameters, this, results); + success = true; + } + catch (HibernateException) + { + // Do not call Convert on HibernateExceptions + throw; + } + catch (Exception e) + { + throw Convert(e, "Could not execute query"); + } + finally + { + dontFlushFromFind--; + AfterOperation(success); + } + } + } - public override IQueryTranslator[] GetQueries(string query, bool scalar) + public override IQueryTranslator[] GetQueries(string query, bool scalar) { - using (new SessionIdLoggingContext(sessionId)) - { - HQLQueryPlan plan = Factory.QueryPlanCache.GetHQLQueryPlan(query, scalar, enabledFilters); - AutoFlushIfRequired(plan.QuerySpaces); - return plan.Translators; - } + using (new SessionIdLoggingContext(sessionId)) + { + HQLQueryPlan plan = Factory.QueryP... [truncated message content] |
From: <aye...@us...> - 2009-05-08 02:22:33
|
Revision: 4265 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4265&view=rev Author: ayenderahien Date: 2009-05-08 01:45:53 +0000 (Fri, 08 May 2009) Log Message: ----------- Adding session id notion that goes into the NDC context Please note that this feature is mostly required for automated tools that need to correlate different log messages from the same session (NHProf) There is no change in the log output if you don't explicitly request is ( using property{sessionId} ) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/Person.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 01:26:08 UTC (rev 4264) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using System.Data; @@ -287,5 +288,7 @@ FutureCriteriaBatch FutureCriteriaBatch { get; } FutureQueryBatch FutureQueryBatch { get; } + + Guid SessionId { get; } } } Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 01:26:08 UTC (rev 4264) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -25,6 +25,8 @@ { [NonSerialized] private ISessionFactoryImplementor factory; + + protected readonly Guid sessionId = Guid.NewGuid(); private bool closed; private System.Transactions.Transaction ambientTransation; private bool isAlreadyDisposed; @@ -32,6 +34,11 @@ private static readonly ILog logger = LogManager.GetLogger(typeof (AbstractSessionImpl)); + public Guid SessionId + { + get { return sessionId; } + } + protected bool TakingPartInDtcTransaction { get @@ -51,7 +58,10 @@ public void Initialize() { - CheckAndUpdateSessionStatus(); + using(new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + } } public abstract void InitializeCollection(IPersistentCollection collection, bool writing); @@ -98,16 +108,20 @@ public virtual IQuery GetNamedSQLQuery(string name) { - CheckAndUpdateSessionStatus(); - NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name); - if (nsqlqd == null) - { - throw new MappingException("Named SQL query not known: " + name); - } - IQuery query = new SqlQueryImpl(nsqlqd, this, factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); - query.SetComment("named native SQL query " + name); - InitQuery(query, nsqlqd); - return query; + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name); + if (nsqlqd == null) + { + throw new MappingException("Named SQL query not known: " + name); + } + IQuery query = new SqlQueryImpl(nsqlqd, this, + factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); + query.SetComment("named native SQL query " + name); + InitQuery(query, nsqlqd); + return query; + } } public abstract IQueryTranslator[] GetQueries(string query, bool scalar); @@ -133,28 +147,33 @@ public virtual IQuery GetNamedQuery(string queryName) { - CheckAndUpdateSessionStatus(); - NamedQueryDefinition nqd = factory.GetNamedQuery(queryName); - IQuery query; - if (nqd != null) - { - string queryString = nqd.QueryString; - query = new QueryImpl(queryString, nqd.FlushMode, this, GetHQLQueryPlan(queryString, false).ParameterMetadata); - query.SetComment("named HQL query " + queryName); - } - else - { - NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName); - if (nsqlqd == null) - { - throw new MappingException("Named query not known: " + queryName); - } - query = new SqlQueryImpl(nsqlqd, this, factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); - query.SetComment("named native SQL query " + queryName); - nqd = nsqlqd; - } - InitQuery(query, nqd); - return query; + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + NamedQueryDefinition nqd = factory.GetNamedQuery(queryName); + IQuery query; + if (nqd != null) + { + string queryString = nqd.QueryString; + query = new QueryImpl(queryString, nqd.FlushMode, this, + GetHQLQueryPlan(queryString, false).ParameterMetadata); + query.SetComment("named HQL query " + queryName); + } + else + { + NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName); + if (nsqlqd == null) + { + throw new MappingException("Named query not known: " + queryName); + } + query = new SqlQueryImpl(nsqlqd, this, + factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString)); + query.SetComment("named native SQL query " + queryName); + nqd = nsqlqd; + } + InitQuery(query, nqd); + return query; + } } public bool IsClosed @@ -164,8 +183,11 @@ protected internal virtual void CheckAndUpdateSessionStatus() { - ErrorIfClosed(); - EnlistInAmbientTransactionIfNeeded(); + using (new SessionIdLoggingContext(sessionId)) + { + ErrorIfClosed(); + EnlistInAmbientTransactionIfNeeded(); + } } protected internal virtual void ErrorIfClosed() @@ -204,136 +226,172 @@ private void InitQuery(IQuery query, NamedQueryDefinition nqd) { - query.SetCacheable(nqd.IsCacheable); - query.SetCacheRegion(nqd.CacheRegion); - if (nqd.Timeout != -1) - { - query.SetTimeout(nqd.Timeout); - } - if (nqd.FetchSize != -1) - { - query.SetFetchSize(nqd.FetchSize); - } - if (nqd.CacheMode.HasValue) - query.SetCacheMode(nqd.CacheMode.Value); + using (new SessionIdLoggingContext(sessionId)) + { + query.SetCacheable(nqd.IsCacheable); + query.SetCacheRegion(nqd.CacheRegion); + if (nqd.Timeout != -1) + { + query.SetTimeout(nqd.Timeout); + } + if (nqd.FetchSize != -1) + { + query.SetFetchSize(nqd.FetchSize); + } + if (nqd.CacheMode.HasValue) + query.SetCacheMode(nqd.CacheMode.Value); - query.SetReadOnly(nqd.IsReadOnly); - if (nqd.Comment != null) - { - query.SetComment(nqd.Comment); - } - query.SetFlushMode(nqd.FlushMode); + query.SetReadOnly(nqd.IsReadOnly); + if (nqd.Comment != null) + { + query.SetComment(nqd.Comment); + } + query.SetFlushMode(nqd.FlushMode); + } } public virtual IQuery CreateQuery(string queryString) { - CheckAndUpdateSessionStatus(); - QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata); - query.SetComment(queryString); - return query; + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata); + query.SetComment(queryString); + return query; + } } public virtual ISQLQuery CreateSQLQuery(string sql) { - CheckAndUpdateSessionStatus(); - SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql)); - query.SetComment("dynamic native SQL query"); - return query; + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql)); + query.SetComment("dynamic native SQL query"); + return query; + } } protected internal virtual HQLQueryPlan GetHQLQueryPlan(string query, bool shallow) { - return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters); + using (new SessionIdLoggingContext(sessionId)) + { + return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters); + } } protected internal virtual NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec) { - return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec); + using (new SessionIdLoggingContext(sessionId)) + { + return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec); + } } protected ADOException Convert(Exception sqlException, string message) { - return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message); + using (new SessionIdLoggingContext(sessionId)) + { + return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message); + } } protected void AfterOperation(bool success) { - if (!ConnectionManager.IsInActiveTransaction) - { - ConnectionManager.AfterNonTransactionalQuery(success); - } + using (new SessionIdLoggingContext(sessionId)) + { + if (!ConnectionManager.IsInActiveTransaction) + { + ConnectionManager.AfterNonTransactionalQuery(success); + } + } } #region IEnlistmentNotification Members void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) { - try - { - using(var tx = new TransactionScope(ambientTransation)) - { - BeforeTransactionCompletion(null); - if (FlushMode != FlushMode.Never) + using (new SessionIdLoggingContext(sessionId)) + { + try + { + using (var tx = new TransactionScope(ambientTransation)) { - using (ConnectionManager.FlushingFromDtcTransaction) - Flush(); + BeforeTransactionCompletion(null); + if (FlushMode != FlushMode.Never) + { + using (ConnectionManager.FlushingFromDtcTransaction) + Flush(); + } + logger.Debug("prepared for DTC transaction"); + + tx.Complete(); } - logger.Debug("prepared for DTC transaction"); + preparingEnlistment.Prepared(); + } + catch (Exception exception) + { + logger.Error("DTC transaction prepre phase failed", exception); + preparingEnlistment.ForceRollback(exception); - tx.Complete(); - } - preparingEnlistment.Prepared(); - } - catch (Exception exception) - { - logger.Error("DTC transaction prepre phase failed", exception); - preparingEnlistment.ForceRollback(exception); - - } + } + } } void IEnlistmentNotification.Commit(Enlistment enlistment) { - logger.Debug("committing DTC transaction"); - // we have nothing to do here, since it is the actual - // DB connection that will commit the transaction - enlistment.Done(); + using (new SessionIdLoggingContext(sessionId)) + { + logger.Debug("committing DTC transaction"); + // we have nothing to do here, since it is the actual + // DB connection that will commit the transaction + enlistment.Done(); + } } void IEnlistmentNotification.Rollback(Enlistment enlistment) { - AfterTransactionCompletion(false, null); - logger.Debug("rolled back DTC transaction"); - enlistment.Done(); + using (new SessionIdLoggingContext(sessionId)) + { + AfterTransactionCompletion(false, null); + logger.Debug("rolled back DTC transaction"); + enlistment.Done(); + } } void IEnlistmentNotification.InDoubt(Enlistment enlistment) { - AfterTransactionCompletion(false, null); - logger.Debug("DTC transaction is in doubt"); - enlistment.Done(); + using (new SessionIdLoggingContext(sessionId)) + { + AfterTransactionCompletion(false, null); + logger.Debug("DTC transaction is in doubt"); + enlistment.Done(); + } } - protected void EnlistInAmbientTransactionIfNeeded() - { - if(ambientTransation != null) - return; - if (System.Transactions.Transaction.Current==null) - return; - ambientTransation = System.Transactions.Transaction.Current.Clone(); - logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel); - AfterTransactionBegin(null); - ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) - { - bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed; - AfterTransactionCompletion(wasSuccessful, null); - if (shouldCloseSessionOnDtcTransactionCompleted) - Dispose(true); - }; - ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); - } + protected void EnlistInAmbientTransactionIfNeeded() + { + using (new SessionIdLoggingContext(sessionId)) + { + if (ambientTransation != null) + return; + if (System.Transactions.Transaction.Current == null) + return; + ambientTransation = System.Transactions.Transaction.Current.Clone(); + logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel); + AfterTransactionBegin(null); + ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) + { + bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed; + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + Dispose(true); + }; + ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); + } + } - protected abstract void Dispose(bool disposing); + protected abstract void Dispose(bool disposing); #endregion } Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 01:26:08 UTC (rev 4264) +++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -65,30 +65,33 @@ public IList List() { - bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; + using (new SessionIdLoggingContext(session.SessionId)) + { + bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; - CreateCriteriaLoaders(); - CombineCriteriaQueries(); + CreateCriteriaLoaders(); + CombineCriteriaQueries(); - if (log.IsDebugEnabled) - { - log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count); - for (int i = 0; i < criteriaQueries.Count; i++) - { - log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]); - } - } + if (log.IsDebugEnabled) + { + log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count); + for (int i = 0; i < criteriaQueries.Count; i++) + { + log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]); + } + } - if (cacheable) - { - criteriaResults = ListUsingQueryCache(); - } - else - { - criteriaResults = ListIgnoreQueryCache(); - } + if (cacheable) + { + criteriaResults = ListUsingQueryCache(); + } + else + { + criteriaResults = ListIgnoreQueryCache(); + } - return criteriaResults; + return criteriaResults; + } } Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 01:26:08 UTC (rev 4264) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -378,27 +378,30 @@ /// </summary> public IList List() { - bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; - combinedParameters = CreateCombinedQueryParameters(); + using (new SessionIdLoggingContext(session.SessionId)) + { + bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable; + combinedParameters = CreateCombinedQueryParameters(); - if (log.IsDebugEnabled) - { - log.DebugFormat("Multi query with {0} queries.", queries.Count); - for (int i = 0; i < queries.Count; i++) - { - log.DebugFormat("Query #{0}: {1}", i, queries[i]); - } - } + if (log.IsDebugEnabled) + { + log.DebugFormat("Multi query with {0} queries.", queries.Count); + for (int i = 0; i < queries.Count; i++) + { + log.DebugFormat("Query #{0}: {1}", i, queries[i]); + } + } - try - { - Before(); - return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache(); - } - finally - { - After(); - } + try + { + Before(); + return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache(); + } + finally + { + After(); + } + } } public IMultiQuery SetFlushMode(FlushMode mode) Added: trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -0,0 +1,51 @@ +using System; +using log4net; + +namespace NHibernate.Impl +{ + public class SessionIdLoggingContext : IDisposable + { + private readonly object oldSessonId; + + public SessionIdLoggingContext(Guid id) + { + oldSessonId = SessionId; + SessionId = id; + } + + /// <summary> + /// Error handling in this case will only kick in if we cannot set values on the TLS + /// this is usally the case if we are called from the finalizer, since this is something + /// that we do only for logging, we ignore the error. + /// </summary> + private static object SessionId + { + get + { + try + { + return ThreadContext.Properties["sessionId"]; + } + catch (Exception) + { + return null; + } + } + set + { + try + { + ThreadContext.Properties["sessionId"] = value; + } + catch (Exception) + { + } + } + } + + public void Dispose() + { + SessionId = oldSessonId; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 01:26:08 UTC (rev 4264) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265) @@ -195,32 +195,35 @@ ConnectionReleaseMode connectionReleaseMode) : base(factory) { - if (interceptor == null) - throw new AssertionFailure("The interceptor can not be null."); + using (new SessionIdLoggingContext(sessionId)) + { + if (interceptor == null) + throw new AssertionFailure("The interceptor can not be null."); - rootSession = null; - this.timestamp = timestamp; - this.entityMode = entityMode; - this.interceptor = interceptor; - listeners = factory.EventListeners; - actionQueue = new ActionQueue(this); - persistenceContext = new StatefulPersistenceContext(this); - this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; - this.autoCloseSessionEnabled = autoCloseSessionEnabled; - this.connectionReleaseMode = connectionReleaseMode; - connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor); + rootSession = null; + this.timestamp = timestamp; + this.entityMode = entityMode; + this.interceptor = interceptor; + listeners = factory.EventListeners; + actionQueue = new ActionQueue(this); + persistenceContext = new StatefulPersistenceContext(this); + this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; + this.autoCloseSessionEnabled = autoCloseSessionEnabled; + this.connectionReleaseMode = connectionReleaseMode; + connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor); - if (factory.Statistics.IsStatisticsEnabled) - { - factory.StatisticsImplementor.OpenSession(); - } + if (factory.Statistics.IsStatisticsEnabled) + { + factory.StatisticsImplementor.OpenSession(); + } - if (log.IsDebugEnabled) - { - log.Debug("opened session at timestamp: " + timestamp); - } + if (log.IsDebugEnabled) + { + log.Debug("opened session at timestamp: " + timestamp); + } - CheckAndUpdateSessionStatus(); + CheckAndUpdateSessionStatus(); + } } /// <summary> @@ -231,24 +234,27 @@ private SessionImpl(SessionImpl parent, EntityMode entityMode) :base (parent.Factory) { - rootSession = parent; - timestamp = parent.timestamp; - connectionManager = parent.connectionManager; - interceptor = parent.interceptor; - listeners = parent.listeners; - actionQueue = new ActionQueue(this); - this.entityMode = entityMode; - persistenceContext = new StatefulPersistenceContext(this); - flushBeforeCompletionEnabled = false; - autoCloseSessionEnabled = false; - connectionReleaseMode = parent.ConnectionReleaseMode; // NH different + using (new SessionIdLoggingContext(sessionId)) + { + rootSession = parent; + timestamp = parent.timestamp; + connectionManager = parent.connectionManager; + interceptor = parent.interceptor; + listeners = parent.listeners; + actionQueue = new ActionQueue(this); + this.entityMode = entityMode; + persistenceContext = new StatefulPersistenceContext(this); + flushBeforeCompletionEnabled = false; + autoCloseSessionEnabled = false; + connectionReleaseMode = parent.ConnectionReleaseMode; // NH different - if (Factory.Statistics.IsStatisticsEnabled) - Factory.StatisticsImplementor.OpenSession(); + if (Factory.Statistics.IsStatisticsEnabled) + Factory.StatisticsImplementor.OpenSession(); - log.Debug("opened session [" + entityMode + "]"); + log.Debug("opened session [" + entityMode + "]"); - CheckAndUpdateSessionStatus(); + CheckAndUpdateSessionStatus(); + } } public override FutureCriteriaBatch FutureCriteriaBatch @@ -313,44 +319,47 @@ /// <summary></summary> public IDbConnection Close() { - log.Debug("closing session"); - if (IsClosed) - { - throw new SessionException("Session was already closed"); - } + using (new SessionIdLoggingContext(sessionId)) + { + log.Debug("closing session"); + if (IsClosed) + { + throw new SessionException("Session was already closed"); + } - if (Factory.Statistics.IsStatisticsEnabled) - { - Factory.StatisticsImplementor.CloseSession(); - } + if (Factory.Statistics.IsStatisticsEnabled) + { + Factory.StatisticsImplementor.CloseSession(); + } - try - { - try - { - if (childSessionsByEntityMode != null) - { - foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode) - { - pair.Value.Close(); - } - } - } - catch - { - // just ignore - } + try + { + try + { + if (childSessionsByEntityMode != null) + { + foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode) + { + pair.Value.Close(); + } + } + } + catch + { + // just ignore + } - if (rootSession == null) - return connectionManager.Close(); - else - return null; - } - finally - { - SetClosed(); - Cleanup(); - } + if (rootSession == null) + return connectionManager.Close(); + else + return null; + } + finally + { + SetClosed(); + Cleanup(); + } + } } /// <summary> @@ -360,65 +369,74 @@ /// </summary> public override void AfterTransactionCompletion(bool success, ITransaction tx) { - log.Debug("transaction completion"); - if (Factory.Statistics.IsStatisticsEnabled) - { - Factory.StatisticsImplementor.EndTransaction(success); - } + using (new SessionIdLoggingContext(sessionId)) + { + log.Debug("transaction completion"); + if (Factory.Statistics.IsStatisticsEnabled) + { + Factory.StatisticsImplementor.EndTransaction(success); + } - connectionManager.AfterTransaction(); - persistenceContext.AfterTransactionCompletion(); - actionQueue.AfterTransactionCompletion(success); - if (rootSession == null) - { - try - { - interceptor.AfterTransactionCompletion(tx); - } - catch (Exception t) - { - log.Error("exception in interceptor afterTransactionCompletion()", t); - } - } + connectionManager.AfterTransaction(); + persistenceContext.AfterTransactionCompletion(); + actionQueue.AfterTransactionCompletion(success); + if (rootSession == null) + { + try + { + interceptor.AfterTransactionCompletion(tx); + } + catch (Exception t) + { + log.Error("exception in interceptor afterTransactionCompletion()", t); + } + } - //if (autoClear) - // Clear(); + //if (autoClear) + // Clear(); + } } private void Cleanup() { - persistenceContext.Clear(); + using (new SessionIdLoggingContext(sessionId)) + { + persistenceContext.Clear(); + } } public LockMode GetCurrentLockMode(object obj) { - CheckAndUpdateSessionStatus(); + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); - if (obj == null) - { - throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); - } - if (obj is INHibernateProxy) - { - obj = ((INHibernateProxy)obj).HibernateLazyInitializer.GetImplementation(this); - if (obj == null) - { - return LockMode.None; - } - } + if (obj == null) + { + throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); + } + if (obj is INHibernateProxy) + { + obj = ((INHibernateProxy) obj).HibernateLazyInitializer.GetImplementation(this); + if (obj == null) + { + return LockMode.None; + } + } - EntityEntry e = persistenceContext.GetEntry(obj); - if (e == null) - { - throw new TransientObjectException("Given object not associated with the session"); - } + EntityEntry e = persistenceContext.GetEntry(obj); + if (e == null) + { + throw new TransientObjectException("Given object not associated with the session"); + } - if (e.Status != Status.Loaded) - { - throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName); - } - return e.LockMode; + if (e.Status != Status.Loaded) + { + throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName); + } + return e.LockMode; + } } public override bool IsOpen @@ -433,12 +451,18 @@ /// <returns></returns> public object Save(object obj) { - return FireSave(new SaveOrUpdateEvent(null, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + return FireSave(new SaveOrUpdateEvent(null, obj, this)); + } } public object Save(string entityName, object obj) { - return FireSave(new SaveOrUpdateEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + return FireSave(new SaveOrUpdateEvent(entityName, obj, this)); + } } /// <summary> @@ -448,7 +472,10 @@ /// <param name="id"></param> public void Save(object obj, object id) { - FireSave(new SaveOrUpdateEvent(null, obj, id, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireSave(new SaveOrUpdateEvent(null, obj, id, this)); + } } /// <summary> @@ -457,38 +484,59 @@ /// <param name="obj"></param> public void Delete(object obj) { - FireDelete(new DeleteEvent(obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireDelete(new DeleteEvent(obj, this)); + } } /// <summary> Delete a persistent object (by explicit entity name)</summary> public void Delete(string entityName, object obj) { - FireDelete(new DeleteEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireDelete(new DeleteEvent(entityName, obj, this)); + } } public void Update(object obj) { - FireUpdate(new SaveOrUpdateEvent(null, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(null, obj, this)); + } } public void Update(string entityName, object obj) { - FireUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + } } public void SaveOrUpdate(object obj) { - FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this)); + } } public void SaveOrUpdate(string entityName, object obj) { - FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this)); + } } public void Update(object obj, object id) { - FireUpdate(new SaveOrUpdateEvent(null, obj, id, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireUpdate(new SaveOrUpdateEvent(null, obj, id, this)); + } } private static readonly object[] NoArgs = new object[0]; @@ -501,168 +549,219 @@ /// <returns></returns> public IList Find(string query) { - return List(query, new QueryParameters()); + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters()); + } } public IList Find(string query, object value, IType type) { - return List(query, new QueryParameters(type, value)); + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters(type, value)); + } } public IList Find(string query, object[] values, IType[] types) { - return List(query, new QueryParameters(types, values)); + using (new SessionIdLoggingContext(sessionId)) + { + return List(query, new QueryParameters(types, values)); + } } public override IList List(string query, QueryParameters parameters) { - IList results = new ArrayList(); - List(query, parameters, results); - return results; + using (new SessionIdLoggingContext(sessionId)) + { + IList results = new ArrayList(); + List(query, parameters, results); + return results; + } } public override IList<T> List<T>(string query, QueryParameters parameters) { - List<T> results = new List<T>(); - List(query, parameters, results); - return results; + using (new SessionIdLoggingContext(sessionId)) + { + List<T> results = new List<T>(); + List(query, parameters, results); + return results; + } } - public override void List(string query, QueryParameters queryParameters, IList results) - { - CheckAndUpdateSessionStatus(); - queryParameters.ValidateParameters(); - HQLQueryPlan plan = GetHQLQueryPlan(query, false); - AutoFlushIfRequired(plan.QuerySpaces); + public override void List(string query, QueryParameters queryParameters, IList results) + { + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + queryParameters.ValidateParameters(); + HQLQueryPlan plan = GetHQLQueryPlan(query, false); + AutoFlushIfRequired(plan.QuerySpaces); - bool success = false; - dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called - try - { - plan.PerformList(queryParameters, this, results); - success = true; - } - catch (HibernateException) - { - // Do not call Convert on HibernateExceptions - throw; - } - catch (Exception e) - { - throw Convert(e, "Could not execute query"); - } - finally - { - dontFlushFromFind--; - AfterOperation(success); - } - } + bool success = false; + dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called + try + { + plan.PerformList(queryParameters, this, results); + success = true; + } + catch (HibernateException) + { + // Do not call Convert on HibernateExceptions + throw; + } + catch (Exception e) + { + throw Convert(e, "Could not execute query"); + } + finally + { + dontFlushFromFind--; + AfterOperation(success); + } + } + } - public override IQueryTranslator[] GetQueries(string query, bool scalar) + public override IQueryTranslator[] GetQueries(string query, bool scalar) { - HQLQueryPlan plan = Factory.QueryPlanCache.GetHQLQueryPlan(query, scalar, enabledFilters); - AutoFlushIfRequired(plan.QuerySpaces); - return plan.Translators; + using (new SessionIdLoggingContext(sessionId)) + { + HQLQueryPlan plan = Factory.QueryPlanCache.GetHQLQueryPlan(query, scalar, enabledFilters); + AutoFlushIfRequired(plan.QuerySpaces); + return plan.Translators; + } } public IEnumerable Enumerable(string query) { - return Enumerable(query, NoArgs, NoTypes); + using (new SessionIdLoggingContext(sessionId)) + { + return Enumerable(query, NoArgs, NoTypes); + } } public IEnumerable Enumerable(string query, object value, IType type) { - return Enumerable(query, new[] { value }, new[] { type }); + using (new SessionIdLoggingContext(sessionId)) + { + return Enumerable(query, new[] {value}, new[] {type}); + } } public IEnumerable Enumerable(string query, object[] values, IType[] types) { - return Enumerable(query, new QueryParameters(types, values)); + using (new SessionIdLoggingContext(sessionId)) + { + return Enumerable(query, new QueryParameters(types, values)); + } } public override IEnumerable<T> Enumerable<T>(string query, QueryParameters queryParameters) { - CheckAndUpdateSessionStatus(); - queryParameters.ValidateParameters(); - HQLQueryPlan plan = GetHQLQueryPlan(query, true); - AutoFlushIfRequired(plan.QuerySpaces); + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + queryParameters.ValidateParameters(); + HQLQueryPlan plan = GetHQLQueryPlan(query, true); + AutoFlushIfRequired(plan.QuerySpaces); - dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called - try - { - return plan.PerformIterate<T>(queryParameters, this); - } - finally - { - dontFlushFromFind--; - } + dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called + try + { + return plan.PerformIterate<T>(queryParameters, this); + } + finally + { + dontFlushFromFind--; + } + } } public override IEnumerable Enumerable(string query, QueryParameters queryParameters) { - CheckAndUpdateSessionStatus(); - queryParameters.ValidateParameters(); - HQLQueryPlan plan = GetHQLQueryPlan(query, true); - AutoFlushIfRequired(plan.QuerySpaces); + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + queryParameters.ValidateParameters(); + HQLQueryPlan plan = GetHQLQueryPlan(query, true); + AutoFlushIfRequired(plan.QuerySpaces); - dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called - try - { - return plan.PerformIterate(queryParameters, this); - } - finally - { - dontFlushFromFind--; - } + dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called + try + { + return plan.PerformIterate(queryParameters, this); + } + finally + { + dontFlushFromFind--; + } + } } // TODO: Scroll(string query, QueryParameters queryParameters) public int Delete(string query) { - return Delete(query, NoArgs, NoTypes); + using (new SessionIdLoggingContext(sessionId)) + { + return Delete(query, NoArgs, NoTypes); + } } public int Delete(string query, object value, IType type) { - return Delete(query, new[] { value }, new[] { type }); + using (new SessionIdLoggingContext(sessionId)) + { + return Delete(query, new[] {value}, new[] {type}); + } } public int Delete(string query, object[] values, IType[] types) { - if (string.IsNullOrEmpty(query)) - { - throw new ArgumentNullException("query", "attempt to perform delete-by-query with null query"); - } + using (new SessionIdLoggingContext(sessionId)) + { + if (string.IsNullOrEmpty(query)) + { + throw new ArgumentNullException("query", "attempt to perform delete-by-query with null query"); + } - CheckAndUpdateSessionStatus(); + CheckAndUpdateSessionStatus(); - if (log.IsDebugEnabled) - { - log.Debug("delete: " + query); - if (values.Length != 0) - { - log.Debug("parameters: " + StringHelper.ToString(values)); - } - } + if (log.IsDebugEnabled) + { + log.Debug("delete: " + query); + if (values.Length != 0) + { + log.Debug("parameters: " + StringHelper.ToString(values)); + } + } - IList list = Find(query, values, types); - int count = list.Count; - for (int i = 0; i < count; i++) - { - Delete(list[i]); - } - return count; + IList list = Find(query, values, types); + int count = list.Count; + for (int i = 0; i < count; i++) + { + Delete(list[i]); + } + return count; + } } public void Lock(object obj, LockMode lockMode) { - FireLock(new LockEvent(obj, lockMode, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireLock(new LockEvent(obj, lockMode, this)); + } } public void Lock(string entityName, object obj, LockMode lockMode) { - FireLock(new LockEvent(entityName, obj, lockMode, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireLock(new LockEvent(entityName, obj, lockMode, this)); + } } /// <summary> @@ -673,74 +772,86 @@ /// <returns></returns> public IQuery CreateFilter(object collection, string queryString) { - CheckAndUpdateSessionStatus(); + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); - CheckAndUpdateSessionStatus(); - CollectionFilterImpl filter = - new CollectionFilterImpl(queryString, collection, this, - GetFilterQueryPlan(collection, queryString, null, false).ParameterMetadata); - //filter.SetComment(queryString); - return filter; + CheckAndUpdateSessionStatus(); + CollectionFilterImpl filter = + new CollectionFilterImpl(queryString, collection, this, + GetFilterQueryPlan(collection, queryString, null, false).ParameterMetadata); + //filter.SetComment(queryString); + return filter; + } } private FilterQueryPlan GetFilterQueryPlan(object collection, string filter, QueryParameters parameters, bool shallow) { - if (collection == null) - { - throw new ArgumentNullException("collection", "null collection passed to filter"); - } + using (new SessionIdLoggingContext(sessionId)) + { + if (collection == null) + { + throw new ArgumentNullException("collection", "null collection passed to filter"); + } - CollectionEntry entry = persistenceContext.GetCollectionEntryOrNull(collection); - ICollectionPersister roleBeforeFlush = (entry == null) ? null : entry.LoadedPersister; + CollectionEntry entry = persistenceContext.GetCollectionEntryOrNull(collection); + ICollectionPersister roleBeforeFlush = (entry == null) ? null : entry.LoadedPersister; - FilterQueryPlan plan; - if (roleBeforeFlush == null) - { - // if it was previously unreferenced, we need to flush in order to - // get its state into the database in order to execute query - Flush(); - entry = persistenceContext.GetCollectionEntryOrNull(collection); - ICollectionPersister roleAfterFlush = (entry == null) ? null : entry.LoadedPersister; - if (roleAfterFlush == null) - { - throw new QueryException("The collection was unreferenced"); - } - plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleAfterFlush.Role, shallow, EnabledFilters); - } - else - { - // otherwise, we only need to flush if there are in-memory changes - // to the queried tables - plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleBeforeFlush.Role, shallow, EnabledFilters); - if (AutoFlushIfRequired(plan.QuerySpaces)) - { - // might need to run a different filter entirely after the flush - // because the collection role may have changed - entry = persistenceContext.GetCollectionEntryOrNull(collection); - ICollectionPersister roleAfterFlush = (entry == null) ? null : entry.LoadedPersister; - if (roleBeforeFlush != roleAfterFlush) - { - if (roleAfterFlush == null) - { - throw new QueryException("The collection was dereferenced"); - } - plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleAfterFlush.Role, shallow, EnabledFilters); - } - } - } + FilterQueryPlan plan; + if (roleBeforeFlush == null) + { + // if it was previously unreferenced, we need to flush in order to + // get its state into the database in order to execute query + Flush(); + entry = persistenceContext.GetCollectionEntryOrNull(collection); + ICollectionPersister roleAfterFlush = (entry == null) ? null : entry.LoadedPersister; + if (roleAfterFlush == null) + { + throw new QueryException("The collection was unreferenced"); + } + plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleAfterFlush.Role, shallow, + EnabledFilters); + } + else + { + // otherwise, we only need to flush if there are in-memory changes + // to the queried tables + plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleBeforeFlush.Role, shallow, + EnabledFilters); + if (AutoFlushIfRequired(plan.QuerySpaces)) + { + // might need to run a different filter entirely after the flush + // because the collection role may have changed + entry = persistenceContext.GetCollectionEntryOrNull(collection); + ICollectionPersister roleAfterFlush = (entry == null) ? null : entry.LoadedPersister; + if (roleBeforeFlush != roleAfterFlush) + { + if (roleAfterFlush == null) + { + throw new QueryException("The collection was dereferenced"); + } + plan = Factory.QueryPlanCache.GetFilterQueryPlan(filter, roleAfterFlush.Role, shallow, + EnabledFilters); + } + } + } - if (parameters != null) - { - parameters.PositionalParameterValues[0] = entry.LoadedKey; - parameters.PositionalParameterTypes[0] = entry.LoadedPersister.KeyType; - } + if (parameters != null) + { + parameters.PositionalParameterValues[0] = entry.LoadedKey; + parameters.PositionalParameterTypes[0] = entry.LoadedPersister.KeyType; + } - return plan; + return plan; + } } public override object Instantiate(string clazz, object id) { - return Instantiate(Factory.GetEntityPersister(clazz), id); + using (new SessionIdLoggingContext(sessionId)) + { + return Instantiate(Factory.GetEntityPersister(clazz), id); + } } /// <summary> Get the ActionQueue for this session</summary> @@ -761,101 +872,145 @@ /// <returns></returns> public object Instantiate(IEntityPersister persister, object id) { - ErrorIfClosed(); - object result = interceptor.Instantiate(persister.EntityName, entityMode, id); - if (result == null) - { - result = persister.Instantiate(id, entityMode); - } - return result; + using (new SessionIdLoggingContext(sessionId)) + { + ErrorIfClosed(); + object result = interceptor.Instantiate(persister.EntityName, entityMode, id); + if (result == null) + { + result = persister.Instantiate(id, entityMode); + } + return result; + } } #region IEventSource Members /// <summary> Force an immediate flush</summary> public void ForceFlush(EntityEntry entityEntry) { - CheckAndUpdateSessionStatus(); - if (log.IsDebugEnabled) - { - log.Debug("flushing to force deletion of re-saved object: " + MessageHelper.InfoString(entityEntry.Persister, entityEntry.Id, Factory)); - } + using (new SessionIdLoggingContext(sessionId)) + { + CheckAndUpdateSessionStatus(); + if (log.IsDebugEnabled) + { + log.Debug("flushing to force deletion of re-saved object: " + + MessageHelper.InfoString(entityEntry.Persister, entityEntry.Id, Factory)); + } - if (persistenceContext.CascadeLevel > 0) - { - throw new ObjectDeletedException( - "deleted object would be re-saved by cascade (remove deleted object from associations)", entityEntry.Id, - entityEntry.EntityName); - } + if (persistenceContext.CascadeLevel > 0) + { + throw new ObjectDeletedException( + "deleted object would be re-saved by cascade (remove deleted object from associations)", + entityEntry.Id, + entityEntry.EntityName); + } - Flush(); + Flush(); + } } /// <summary> Cascade merge an entity instance</summary> public void Merge(string entityName, object obj, IDictionary copiedAlready) { - FireMerge(copiedAlready, new MergeEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireMerge(copiedAlready, new MergeEvent(entityName, obj, this)); + } } /// <summary> Cascade persist an entity instance</summary> public void Persist(string entityName, object obj, IDictionary createdAlready) { - FirePersist(createdAlready, new PersistEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FirePersist(createdAlready, new PersistEvent(entityName, obj, this)); + } } /// <summary> Cascade persist an entity instance during the flush process</summary> public void PersistOnFlush(string entityName, object obj, IDictionary copiedAlready) { - FirePersistOnFlush(copiedAlready, new PersistEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FirePersistOnFlush(copiedAlready, new PersistEvent(entityName, obj, this)); + } } /// <summary> Cascade refresh an entity instance</summary> public void Refresh(object obj, IDictionary refreshedAlready) { - FireRefresh(refreshedAlready, new RefreshEvent(obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireRefresh(refreshedAlready, new RefreshEvent(obj, this)); + } } /// <summary> Cascade copy an entity instance</summary> public void SaveOrUpdateCopy(string entityName, object obj, IDictionary copiedAlready) { - FireSaveOrUpdateCopy(copiedAlready, new MergeEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FireSaveOrUpdateCopy(copiedAlready, new MergeEvent(entityName, obj, this)); + } } /// <summary> Cascade delete an entity instance</summary> public void Delete(string entityName, object child, bool isCascadeDeleteEnabled, ISet transientEntities) { - FireDelete(new DeleteEvent(entityName, child, isCascadeDeleteEnabled, this), transientEntities); + using (new SessionIdLoggingContext(sessionId)) + { + FireDelete(new DeleteEvent(entityName, child, isCascadeDeleteEnabled, this), transientEntities); + } } #endregion public object Merge(string entityName, object obj) { - return FireMerge(new MergeEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + return FireMerge(new MergeEvent(entityName, obj, this)); + } } public object Merge(object obj) { - return Merge(null, obj); + using (new SessionIdLoggingContext(sessionId)) + { + return Merge(null, obj); + } } public void Persist(string entityName, object obj) { - FirePersist(new PersistEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FirePersist(new PersistEvent(entityName, obj, this)); + } } public void Persist(object obj) { - Persist(null, obj); + using (new SessionIdLoggingContext(sessionId)) + { + Persist(null, obj); + } } public void PersistOnFlush(string entityName, object obj) { - FirePersistOnFlush(new PersistEvent(entityName, obj, this)); + using (new SessionIdLoggingContext(sessionId)) + { + FirePersistOnFlush(new PersistEvent(entityName, obj, this)); + } } public void PersistOnFlush(object obj) { - Persist(null, obj); + using (new SessionIdLoggingContext(sessionId)) + { + Persist(null, obj); + } } /// <summary></summary> @@ -872,39 +1027,45 @@ public override string BestGuessEntityName(object entity) { - INHibernateProxy proxy = entity as INHibernateProxy; - if (proxy != null) - { - ILazyInitializer initializer = proxy.HibernateLazyInitializer; + using (new SessionIdLoggingContext(sessionId)) + { + INHibernateProxy proxy = entity as INHibernateProxy; + if (proxy != null) + { + ILazyInitializer initializer = proxy.HibernateLazyInitializer; - // it is possible for this method to be called during flush processing, - // so make certain that we do not accidently initialize an uninitialized proxy - if (initializer.IsUninitialized) - { - return initializer.PersistentClass.FullName; - } - entity = initializer.GetImplementation(); - } - EntityEntry entry = persistenceContext.GetEntry(entity); - if (entry == null) - { - return GuessEntityName(entity); - } - else - { - return entry.Persister.EntityName; - } + // it is possible for this method to be called during flush processing, + // so make certain that we do not accidently initialize an uninitialized proxy + if (initializer.IsUninitialized) + { + return initializer.PersistentClass.FullName; + } + entity = initializer.GetImplementation(); + } + EntityEntry entry = persistenceContext.GetEntry(entity); + if (entry == null) + { + return GuessEntityName(entity); + } + else + { + return entry.Persister.EntityName; + } + } } public override string GuessEntityName(object entity) { - string entityName = interceptor.GetEntityName(entity); - if (entityName == null) - { - System.Type t = entity.GetType(); - entityName = Fac... [truncated message content] |
From: <aye...@us...> - 2009-05-08 01:26:15
|
Revision: 4264 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4264&view=rev Author: ayenderahien Date: 2009-05-08 01:26:08 +0000 (Fri, 08 May 2009) Log Message: ----------- DebugConnectionProvider will now report what connection it is trying to connect with when it is failing to connect Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/DebugConnectionProvider.cs Modified: trunk/nhibernate/src/NHibernate.Test/DebugConnectionProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DebugConnectionProvider.cs 2009-05-08 00:04:03 UTC (rev 4263) +++ trunk/nhibernate/src/NHibernate.Test/DebugConnectionProvider.cs 2009-05-08 01:26:08 UTC (rev 4264) @@ -16,9 +16,17 @@ public override IDbConnection GetConnection() { - IDbConnection connection = base.GetConnection(); - connections.Add(connection); - return connection; + try + { + IDbConnection connection = base.GetConnection(); + connections.Add(connection); + return connection; + } + catch (Exception e) + { + throw new HibernateException("Could not open connection to: " + ConnectionString, e); + } + } public override void CloseConnection(IDbConnection conn) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |