From: <fab...@us...> - 2009-05-06 16:10:30
|
Revision: 4254 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4254&view=rev Author: fabiomaulo Date: 2009-05-06 16:10:29 +0000 (Wed, 06 May 2009) Log Message: ----------- End porting tests for UPDATE executable HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-06 14:54:55 UTC (rev 4253) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-06 16:10:29 UTC (rev 4254) @@ -37,7 +37,16 @@ // knows about the property-ref path in the correct format; it is either this, or // recurse over the DotNodes constructing the property path just like DotNode does // internally - var lhs = (DotNode)eq.GetFirstChild(); + DotNode lhs; + try + { + lhs = (DotNode)eq.GetFirstChild(); + } + catch (InvalidCastException e) + { + throw new QueryException( + string.Format("Left side of assigment should be a case sensitive property or a field (depending on mapping); found '{0}'", eq.GetFirstChild()), e); + } var rhs = (SqlNode)lhs.NextSibling; ValidateLhs(lhs); Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-06 14:54:55 UTC (rev 4253) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-06 16:10:29 UTC (rev 4254) @@ -357,6 +357,86 @@ s.Close(); data.Cleanup(); + } + + [Test] + public void UpdateSetNullUnionSubclass() + { + var data = new TestData(this); + data.Prepare(); + + // These should reach out into *all* subclass tables... + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("update Vehicle set Owner = 'Steve'").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(4), "incorrect restricted update count"); + count = s.CreateQuery("update Vehicle set Owner = null where Owner = 'Steve'").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(4), "incorrect restricted update count"); + + count = s.CreateQuery("delete Vehicle where Owner is null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(4), "incorrect restricted update count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] + public void WrongPropertyNameThrowQueryException() + { + using (ISession s = OpenSession()) + { + var e = Assert.Throws<QueryException>(() => s.CreateQuery("update Vehicle set owner = null where owner = 'Steve'").ExecuteUpdate()); + Assert.That(e.Message, Text.StartsWith("Left side of assigment should be a case sensitive property or a field")); + } + } + + [Test] + public void UpdateSetNullOnDiscriminatorSubclass() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("update PettingZoo set address.city = null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + count = s.CreateQuery("delete Zoo where address.city is null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + + count = s.CreateQuery("update Zoo set address.city = null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + count = s.CreateQuery("delete Zoo where address.city is null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] + public void UpdateSetNullOnJoinedSubclass() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("update Mammal set bodyWeight = null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(2), "Incorrect deletion count on joined subclass"); + + count = s.CreateQuery("delete Animal where bodyWeight = null").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(2), "Incorrect deletion count on joined subclass"); + + t.Commit(); + s.Close(); + + data.Cleanup(); } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-06 21:50:47
|
Revision: 4255 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4255&view=rev Author: fabiomaulo Date: 2009-05-06 21:50:40 +0000 (Wed, 06 May 2009) Log Message: ----------- Starting port of AST tests for Inserts Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-05-06 16:10:29 UTC (rev 4254) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2009-05-06 21:50:40 UTC (rev 4255) @@ -1,4 +1,4 @@ -// $ANTLR 3.1.2 C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g 2009-05-05 16:13:02 +// $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 @@ -665,16 +665,16 @@ // AST REWRITE - // elements: w, u, s, f + // elements: u, f, s, w // token labels: u - // rule labels: f, w, retval, s + // 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_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.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); @@ -956,8 +956,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:84:2: ( ^( INTO (p= path ) ps= insertablePropertySpec ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:84:4: ^( INTO (p= path ) ps= insertablePropertySpec ) + // 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(); @@ -966,7 +966,7 @@ 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_intoClause341); + INTO12=(IASTNode)Match(input,INTO,FOLLOW_INTO_in_intoClause347); INTO12_tree = (IASTNode)adaptor.DupNode(INTO12); root_1 = (IASTNode)adaptor.BecomeRoot(INTO12_tree, root_1); @@ -975,11 +975,11 @@ HandleClauseStart( INTO ); Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:84:43: (p= path ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:84:44: p= path + // 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_intoClause348); + PushFollow(FOLLOW_path_in_intoClause354); p = path(); state.followingStackPointer--; @@ -988,7 +988,7 @@ } _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_insertablePropertySpec_in_intoClause353); + PushFollow(FOLLOW_insertablePropertySpec_in_intoClause359); ps = insertablePropertySpec(); state.followingStackPointer--; @@ -998,13 +998,13 @@ } - retval.Tree = CreateIntoClause(((p != null) ? p.p : default(String)), ((ps != null) ? ((IASTNode)ps.Tree) : null)); - - } 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) { @@ -1029,7 +1029,7 @@ }; // $ANTLR start "insertablePropertySpec" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:89:1: insertablePropertySpec : ^( RANGE ( IDENT )+ ) ; + // 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(); @@ -1048,8 +1048,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:90:2: ( ^( RANGE ( IDENT )+ ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:90:4: ^( RANGE ( IDENT )+ ) + // 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(); @@ -1058,7 +1058,7 @@ 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_insertablePropertySpec370); + RANGE13=(IASTNode)Match(input,RANGE,FOLLOW_RANGE_in_insertablePropertySpec375); RANGE13_tree = (IASTNode)adaptor.DupNode(RANGE13); root_1 = (IASTNode)adaptor.BecomeRoot(RANGE13_tree, root_1); @@ -1066,7 +1066,7 @@ Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:90:13: ( IDENT )+ + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:91:13: ( IDENT )+ int cnt5 = 0; do { @@ -1082,10 +1082,10 @@ switch (alt5) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:90:14: IDENT + // 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_insertablePropertySpec373); + IDENT14=(IASTNode)Match(input,IDENT,FOLLOW_IDENT_in_insertablePropertySpec378); IDENT14_tree = (IASTNode)adaptor.DupNode(IDENT14); adaptor.AddChild(root_1, IDENT14_tree); @@ -1139,7 +1139,7 @@ }; // $ANTLR start "setClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:93:1: setClause : ^( SET ( assignment )* ) ; + // 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(); @@ -1158,8 +1158,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:94:2: ( ^( SET ( assignment )* ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:94:4: ^( SET ( assignment )* ) + // 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(); @@ -1168,7 +1168,7 @@ 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_setClause390); + SET15=(IASTNode)Match(input,SET,FOLLOW_SET_in_setClause395); SET15_tree = (IASTNode)adaptor.DupNode(SET15); root_1 = (IASTNode)adaptor.BecomeRoot(SET15_tree, root_1); @@ -1179,7 +1179,7 @@ if ( input.LA(1) == Token.DOWN ) { Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:94:41: ( assignment )* + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:41: ( assignment )* do { int alt6 = 2; @@ -1194,10 +1194,10 @@ switch (alt6) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:94:42: assignment + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:95:42: assignment { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_assignment_in_setClause395); + PushFollow(FOLLOW_assignment_in_setClause400); assignment16 = assignment(); state.followingStackPointer--; @@ -1248,7 +1248,7 @@ }; // $ANTLR start "assignment" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:97:1: assignment : ^( EQ (p= propertyRef ) ( newValue ) ) ; + // 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(); @@ -1269,8 +1269,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:2: ( ^( EQ (p= propertyRef ) ( newValue ) ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:4: ^( EQ (p= propertyRef ) ( newValue ) ) + // 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(); @@ -1279,7 +1279,7 @@ 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_assignment422); + EQ17=(IASTNode)Match(input,EQ,FOLLOW_EQ_in_assignment427); EQ17_tree = (IASTNode)adaptor.DupNode(EQ17); root_1 = (IASTNode)adaptor.BecomeRoot(EQ17_tree, root_1); @@ -1287,11 +1287,11 @@ Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:10: (p= propertyRef ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:11: p= propertyRef + // 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_assignment427); + PushFollow(FOLLOW_propertyRef_in_assignment432); p = propertyRef(); state.followingStackPointer--; @@ -1300,11 +1300,11 @@ } Resolve(((p != null) ? ((IASTNode)p.Tree) : null)); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:48: ( newValue ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:103:49: newValue + // 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_assignment433); + PushFollow(FOLLOW_newValue_in_assignment438); newValue18 = newValue(); state.followingStackPointer--; @@ -1348,7 +1348,7 @@ }; // $ANTLR start "newValue" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:107:1: newValue : ( expr | query ); + // 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(); @@ -1367,7 +1367,7 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:108:2: ( expr | query ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:109:2: ( expr | query ) int alt7 = 2; int LA7_0 = input.LA(1); @@ -1389,12 +1389,12 @@ switch (alt7) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:108:4: expr + // 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_newValue449); + PushFollow(FOLLOW_expr_in_newValue454); expr19 = expr(); state.followingStackPointer--; @@ -1403,12 +1403,12 @@ } break; case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:108:11: query + // 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_newValue453); + PushFollow(FOLLOW_query_in_newValue458); query20 = query(); state.followingStackPointer--; @@ -1444,7 +1444,7 @@ }; // $ANTLR start "query" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:113:1: query : ^( 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: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(); @@ -1479,15 +1479,15 @@ RewriteRuleSubtreeStream stream_selectClause = new RewriteRuleSubtreeStream(adaptor,"rule selectClause"); try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:120: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:120:4: ^( QUERY ^( SELECT_FROM f= fromClause (s= selectClause )? ) (w= whereClause )? (g= groupClause )? (o= orderClause )? ) + // 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_query475); + QUERY21=(IASTNode)Match(input,QUERY,FOLLOW_QUERY_in_query480); stream_QUERY.Add(QUERY21); @@ -1499,19 +1499,19 @@ 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_query487); + 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_query495); + 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:124:5: (s= selectClause )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:125:5: (s= selectClause )? int alt8 = 2; int LA8_0 = input.LA(1); @@ -1522,10 +1522,10 @@ switch (alt8) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:124:6: s= selectClause + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:125:6: s= selectClause { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectClause_in_query504); + PushFollow(FOLLOW_selectClause_in_query509); s = selectClause(); state.followingStackPointer--; @@ -1540,7 +1540,7 @@ 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:126:4: (w= whereClause )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:4: (w= whereClause )? int alt9 = 2; int LA9_0 = input.LA(1); @@ -1551,10 +1551,10 @@ switch (alt9) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:126:5: w= whereClause + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:5: w= whereClause { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_whereClause_in_query519); + PushFollow(FOLLOW_whereClause_in_query524); w = whereClause(); state.followingStackPointer--; @@ -1565,7 +1565,7 @@ } - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:4: (g= groupClause )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:4: (g= groupClause )? int alt10 = 2; int LA10_0 = input.LA(1); @@ -1576,10 +1576,10 @@ switch (alt10) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:127:5: g= groupClause + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:5: g= groupClause { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_groupClause_in_query529); + PushFollow(FOLLOW_groupClause_in_query534); g = groupClause(); state.followingStackPointer--; @@ -1590,7 +1590,7 @@ } - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:4: (o= orderClause )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:129:4: (o= orderClause )? int alt11 = 2; int LA11_0 = input.LA(1); @@ -1601,10 +1601,10 @@ switch (alt11) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:128:5: o= orderClause + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:129:5: o= orderClause { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_orderClause_in_query539); + PushFollow(FOLLOW_orderClause_in_query544); o = orderClause(); state.followingStackPointer--; @@ -1622,29 +1622,29 @@ // AST REWRITE - // elements: s, f, g, w, o + // elements: s, o, w, f, g // token labels: - // rule labels: w, f, g, retval, s, o + // 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_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.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(); - // 130:2: -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) + // 131:2: -> ^( SELECT ( $s)? $f ( $w)? ( $g)? ( $o)? ) { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:130:5: ^( 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:130:14: ( $s)? + // 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()); @@ -1652,21 +1652,21 @@ } stream_s.Reset(); adaptor.AddChild(root_1, stream_f.NextTree()); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:130:21: ( $w)? + // 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:130:25: ( $g)? + // 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:130:29: ( $o)? + // 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()); @@ -1714,7 +1714,7 @@ }; // $ANTLR start "orderClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:133:1: orderClause : ^( ORDER orderExprs ) ; + // 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(); @@ -1733,8 +1733,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:134:2: ( ^( ORDER orderExprs ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:134:4: ^( ORDER orderExprs ) + // 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(); @@ -1743,7 +1743,7 @@ 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_orderClause584); + ORDER23=(IASTNode)Match(input,ORDER,FOLLOW_ORDER_in_orderClause589); ORDER23_tree = (IASTNode)adaptor.DupNode(ORDER23); root_1 = (IASTNode)adaptor.BecomeRoot(ORDER23_tree, root_1); @@ -1753,7 +1753,7 @@ Match(input, Token.DOWN, null); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_orderExprs_in_orderClause588); + PushFollow(FOLLOW_orderExprs_in_orderClause593); orderExprs24 = orderExprs(); state.followingStackPointer--; @@ -1791,7 +1791,7 @@ }; // $ANTLR start "orderExprs" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:137:1: orderExprs : expr ( ASCENDING | DESCENDING )? ( orderExprs )? ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:1: orderExprs : expr ( ASCENDING | DESCENDING )? ( orderExprs )? ; public HqlSqlWalker.orderExprs_return orderExprs() // throws RecognitionException [1] { HqlSqlWalker.orderExprs_return retval = new HqlSqlWalker.orderExprs_return(); @@ -1812,18 +1812,18 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:2: ( expr ( ASCENDING | DESCENDING )? ( orderExprs )? ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:4: expr ( ASCENDING | DESCENDING )? ( orderExprs )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:139:2: ( expr ( ASCENDING | DESCENDING )? ( orderExprs )? ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:139:4: expr ( ASCENDING | DESCENDING )? ( orderExprs )? { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_expr_in_orderExprs600); + PushFollow(FOLLOW_expr_in_orderExprs605); expr25 = expr(); state.followingStackPointer--; adaptor.AddChild(root_0, expr25.Tree); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:9: ( ASCENDING | DESCENDING )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:139:9: ( ASCENDING | DESCENDING )? int alt12 = 2; int LA12_0 = input.LA(1); @@ -1860,7 +1860,7 @@ } - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:37: ( orderExprs )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:139:37: ( orderExprs )? int alt13 = 2; int LA13_0 = input.LA(1); @@ -1871,10 +1871,10 @@ switch (alt13) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:138:38: orderExprs + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:139:38: orderExprs { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_orderExprs_in_orderExprs614); + PushFollow(FOLLOW_orderExprs_in_orderExprs619); orderExprs27 = orderExprs(); state.followingStackPointer--; @@ -1914,7 +1914,7 @@ }; // $ANTLR start "groupClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:141:1: groupClause : ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:1: groupClause : ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ; public HqlSqlWalker.groupClause_return groupClause() // throws RecognitionException [1] { HqlSqlWalker.groupClause_return retval = new HqlSqlWalker.groupClause_return(); @@ -1937,8 +1937,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:2: ( ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:4: ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:2: ( ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:4: ^( GROUP ( expr )+ ( ^( HAVING logicalExpr ) )? ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -1947,7 +1947,7 @@ IASTNode _save_last_1 = _last; IASTNode _first_1 = null; IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - GROUP28=(IASTNode)Match(input,GROUP,FOLLOW_GROUP_in_groupClause628); + GROUP28=(IASTNode)Match(input,GROUP,FOLLOW_GROUP_in_groupClause633); GROUP28_tree = (IASTNode)adaptor.DupNode(GROUP28); root_1 = (IASTNode)adaptor.BecomeRoot(GROUP28_tree, root_1); @@ -1956,7 +1956,7 @@ HandleClauseStart( GROUP ); Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:44: ( expr )+ + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:44: ( expr )+ int cnt14 = 0; do { @@ -1972,10 +1972,10 @@ switch (alt14) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:45: expr + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:45: expr { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_expr_in_groupClause633); + PushFollow(FOLLOW_expr_in_groupClause638); expr29 = expr(); state.followingStackPointer--; @@ -1996,7 +1996,7 @@ loop14: ; // Stops C# compiler whinging that label 'loop14' has no statements - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:52: ( ^( HAVING logicalExpr ) )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:52: ( ^( HAVING logicalExpr ) )? int alt15 = 2; int LA15_0 = input.LA(1); @@ -2007,14 +2007,14 @@ switch (alt15) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:142:54: ^( HAVING logicalExpr ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:143:54: ^( HAVING logicalExpr ) { _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); - HAVING30=(IASTNode)Match(input,HAVING,FOLLOW_HAVING_in_groupClause640); + HAVING30=(IASTNode)Match(input,HAVING,FOLLOW_HAVING_in_groupClause645); HAVING30_tree = (IASTNode)adaptor.DupNode(HAVING30); root_2 = (IASTNode)adaptor.BecomeRoot(HAVING30_tree, root_2); @@ -2023,7 +2023,7 @@ Match(input, Token.DOWN, null); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_logicalExpr_in_groupClause642); + PushFollow(FOLLOW_logicalExpr_in_groupClause647); logicalExpr31 = logicalExpr(); state.followingStackPointer--; @@ -2071,7 +2071,7 @@ }; // $ANTLR start "selectClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:145:1: selectClause : ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:146:1: selectClause : ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ; public HqlSqlWalker.selectClause_return selectClause() // throws RecognitionException [1] { HqlSqlWalker.selectClause_return retval = new HqlSqlWalker.selectClause_return(); @@ -2094,22 +2094,22 @@ RewriteRuleSubtreeStream stream_selectExprList = new RewriteRuleSubtreeStream(adaptor,"rule selectExprList"); try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:146:2: ( ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:146:4: ^( SELECT (d= DISTINCT )? x= selectExprList ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:2: ( ^( SELECT (d= DISTINCT )? x= selectExprList ) -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:4: ^( SELECT (d= DISTINCT )? x= selectExprList ) { _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); - SELECT32=(IASTNode)Match(input,SELECT,FOLLOW_SELECT_in_selectClause661); + SELECT32=(IASTNode)Match(input,SELECT,FOLLOW_SELECT_in_selectClause666); stream_SELECT.Add(SELECT32); HandleClauseStart( SELECT ); BeforeSelectClause(); Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:146:68: (d= DISTINCT )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:68: (d= DISTINCT )? int alt16 = 2; int LA16_0 = input.LA(1); @@ -2120,10 +2120,10 @@ switch (alt16) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:146:69: d= DISTINCT + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:69: d= DISTINCT { _last = (IASTNode)input.LT(1); - d=(IASTNode)Match(input,DISTINCT,FOLLOW_DISTINCT_in_selectClause668); + d=(IASTNode)Match(input,DISTINCT,FOLLOW_DISTINCT_in_selectClause673); stream_DISTINCT.Add(d); @@ -2133,7 +2133,7 @@ } _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectExprList_in_selectClause674); + PushFollow(FOLLOW_selectExprList_in_selectClause679); x = selectExprList(); state.followingStackPointer--; @@ -2157,14 +2157,14 @@ RewriteRuleSubtreeStream stream_x = new RewriteRuleSubtreeStream(adaptor, "rule x", x!=null ? x.Tree : null); root_0 = (IASTNode)adaptor.GetNilNode(); - // 147:2: -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) + // 148:2: -> ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:5: ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:148:5: ^( SELECT_CLAUSE[\"{select clause}\"] ( $d)? $x) { IASTNode root_1 = (IASTNode)adaptor.GetNilNode(); root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(SELECT_CLAUSE, "{select clause}"), root_1); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:147:40: ( $d)? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:148:40: ( $d)? if ( stream_d.HasNext() ) { adaptor.AddChild(root_1, stream_d.NextNode()); @@ -2207,7 +2207,7 @@ }; // $ANTLR start "selectExprList" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:150:1: selectExprList : ( selectExpr | aliasedSelectExpr )+ ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:151:1: selectExprList : ( selectExpr | aliasedSelectExpr )+ ; public HqlSqlWalker.selectExprList_return selectExprList() // throws RecognitionException [1] { HqlSqlWalker.selectExprList_return retval = new HqlSqlWalker.selectExprList_return(); @@ -2230,12 +2230,12 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:154:2: ( ( selectExpr | aliasedSelectExpr )+ ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:154:4: ( selectExpr | aliasedSelectExpr )+ + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:155:2: ( ( selectExpr | aliasedSelectExpr )+ ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:155:4: ( selectExpr | aliasedSelectExpr )+ { root_0 = (IASTNode)adaptor.GetNilNode(); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:154:4: ( selectExpr | aliasedSelectExpr )+ + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:155:4: ( selectExpr | aliasedSelectExpr )+ int cnt17 = 0; do { @@ -2255,10 +2255,10 @@ switch (alt17) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:154:6: selectExpr + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:155:6: selectExpr { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectExpr_in_selectExprList709); + PushFollow(FOLLOW_selectExpr_in_selectExprList714); selectExpr33 = selectExpr(); state.followingStackPointer--; @@ -2267,10 +2267,10 @@ } break; case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:154:19: aliasedSelectExpr + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:155:19: aliasedSelectExpr { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_aliasedSelectExpr_in_selectExprList713); + PushFollow(FOLLOW_aliasedSelectExpr_in_selectExprList718); aliasedSelectExpr34 = aliasedSelectExpr(); state.followingStackPointer--; @@ -2323,7 +2323,7 @@ }; // $ANTLR start "aliasedSelectExpr" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:159:1: aliasedSelectExpr : ^( AS se= selectExpr i= identifier ) ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:160:1: aliasedSelectExpr : ^( AS se= selectExpr i= identifier ) ; public HqlSqlWalker.aliasedSelectExpr_return aliasedSelectExpr() // throws RecognitionException [1] { HqlSqlWalker.aliasedSelectExpr_return retval = new HqlSqlWalker.aliasedSelectExpr_return(); @@ -2344,8 +2344,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:164:2: ( ^( AS se= selectExpr i= identifier ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:164:4: ^( AS se= selectExpr i= identifier ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:165:2: ( ^( AS se= selectExpr i= identifier ) ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:165:4: ^( AS se= selectExpr i= identifier ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2354,7 +2354,7 @@ IASTNode _save_last_1 = _last; IASTNode _first_1 = null; IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - AS35=(IASTNode)Match(input,AS,FOLLOW_AS_in_aliasedSelectExpr737); + AS35=(IASTNode)Match(input,AS,FOLLOW_AS_in_aliasedSelectExpr742); AS35_tree = (IASTNode)adaptor.DupNode(AS35); root_1 = (IASTNode)adaptor.BecomeRoot(AS35_tree, root_1); @@ -2363,13 +2363,13 @@ Match(input, Token.DOWN, null); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_selectExpr_in_aliasedSelectExpr741); + PushFollow(FOLLOW_selectExpr_in_aliasedSelectExpr746); se = selectExpr(); state.followingStackPointer--; adaptor.AddChild(root_1, se.Tree); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_identifier_in_aliasedSelectExpr745); + PushFollow(FOLLOW_identifier_in_aliasedSelectExpr750); i = identifier(); state.followingStackPointer--; @@ -2411,7 +2411,7 @@ }; // $ANTLR start "selectExpr" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:167:1: selectExpr : (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ); + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:168:1: selectExpr : (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ); public HqlSqlWalker.selectExpr_return selectExpr() // throws RecognitionException [1] { HqlSqlWalker.selectExpr_return retval = new HqlSqlWalker.selectExpr_return(); @@ -2450,7 +2450,7 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:168:2: (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:169:2: (p= propertyRef | ^( ALL ar2= aliasRef ) | ^( OBJECT ar3= aliasRef ) | con= constructor | functionCall | count | collectionFunction | literal | arithmeticExpr | query ) int alt18 = 10; switch ( input.LA(1) ) { @@ -2528,12 +2528,12 @@ switch (alt18) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:168:4: p= propertyRef + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:169:4: p= propertyRef { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_propertyRef_in_selectExpr760); + PushFollow(FOLLOW_propertyRef_in_selectExpr765); p = propertyRef(); state.followingStackPointer--; @@ -2543,7 +2543,7 @@ } break; case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:169:4: ^( ALL ar2= aliasRef ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:170:4: ^( ALL ar2= aliasRef ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2552,7 +2552,7 @@ IASTNode _save_last_1 = _last; IASTNode _first_1 = null; IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - ALL36=(IASTNode)Match(input,ALL,FOLLOW_ALL_in_selectExpr772); + ALL36=(IASTNode)Match(input,ALL,FOLLOW_ALL_in_selectExpr777); ALL36_tree = (IASTNode)adaptor.DupNode(ALL36); root_1 = (IASTNode)adaptor.BecomeRoot(ALL36_tree, root_1); @@ -2561,7 +2561,7 @@ Match(input, Token.DOWN, null); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_aliasRef_in_selectExpr776); + PushFollow(FOLLOW_aliasRef_in_selectExpr781); ar2 = aliasRef(); state.followingStackPointer--; @@ -2575,7 +2575,7 @@ } break; case 3 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:170:4: ^( OBJECT ar3= aliasRef ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:171:4: ^( OBJECT ar3= aliasRef ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2584,7 +2584,7 @@ IASTNode _save_last_1 = _last; IASTNode _first_1 = null; IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - OBJECT37=(IASTNode)Match(input,OBJECT,FOLLOW_OBJECT_in_selectExpr788); + OBJECT37=(IASTNode)Match(input,OBJECT,FOLLOW_OBJECT_in_selectExpr793); OBJECT37_tree = (IASTNode)adaptor.DupNode(OBJECT37); root_1 = (IASTNode)adaptor.BecomeRoot(OBJECT37_tree, root_1); @@ -2593,7 +2593,7 @@ Match(input, Token.DOWN, null); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_aliasRef_in_selectExpr792); + PushFollow(FOLLOW_aliasRef_in_selectExpr797); ar3 = aliasRef(); state.followingStackPointer--; @@ -2607,12 +2607,12 @@ } break; case 4 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:171:4: con= constructor + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:172:4: con= constructor { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_constructor_in_selectExpr803); + PushFollow(FOLLOW_constructor_in_selectExpr808); con = constructor(); state.followingStackPointer--; @@ -2622,12 +2622,12 @@ } break; case 5 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:172:4: functionCall + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:173:4: functionCall { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_functionCall_in_selectExpr814); + PushFollow(FOLLOW_functionCall_in_selectExpr819); functionCall38 = functionCall(); state.followingStackPointer--; @@ -2636,12 +2636,12 @@ } break; case 6 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:173:4: count + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:174:4: count { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_count_in_selectExpr819); + PushFollow(FOLLOW_count_in_selectExpr824); count39 = count(); state.followingStackPointer--; @@ -2650,12 +2650,12 @@ } break; case 7 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:174:4: collectionFunction + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:175:4: collectionFunction { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_collectionFunction_in_selectExpr824); + PushFollow(FOLLOW_collectionFunction_in_selectExpr829); collectionFunction40 = collectionFunction(); state.followingStackPointer--; @@ -2664,12 +2664,12 @@ } break; case 8 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:175:4: literal + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:176:4: literal { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_literal_in_selectExpr832); + PushFollow(FOLLOW_literal_in_selectExpr837); literal41 = literal(); state.followingStackPointer--; @@ -2678,12 +2678,12 @@ } break; case 9 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:176:4: arithmeticExpr + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:177:4: arithmeticExpr { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_arithmeticExpr_in_selectExpr837); + PushFollow(FOLLOW_arithmeticExpr_in_selectExpr842); arithmeticExpr42 = arithmeticExpr(); state.followingStackPointer--; @@ -2692,12 +2692,12 @@ } break; case 10 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:177:4: query + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:178:4: query { root_0 = (IASTNode)adaptor.GetNilNode(); _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_query_in_selectExpr842); + PushFollow(FOLLOW_query_in_selectExpr847); query43 = query(); state.followingStackPointer--; @@ -2733,7 +2733,7 @@ }; // $ANTLR start "count" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:180:1: count : ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ; + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:1: count : ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ; public HqlSqlWalker.count_return count() // throws RecognitionException [1] { HqlSqlWalker.count_return retval = new HqlSqlWalker.count_return(); @@ -2756,8 +2756,8 @@ try { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:2: ( ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:4: ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:182:2: ( ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:182:4: ^( COUNT ( DISTINCT | ALL )? ( aggregateExpr | ROW_STAR ) ) { root_0 = (IASTNode)adaptor.GetNilNode(); @@ -2766,7 +2766,7 @@ IASTNode _save_last_1 = _last; IASTNode _first_1 = null; IASTNode root_1 = (IASTNode)adaptor.GetNilNode();_last = (IASTNode)input.LT(1); - COUNT44=(IASTNode)Match(input,COUNT,FOLLOW_COUNT_in_count854); + COUNT44=(IASTNode)Match(input,COUNT,FOLLOW_COUNT_in_count859); COUNT44_tree = (IASTNode)adaptor.DupNode(COUNT44); root_1 = (IASTNode)adaptor.BecomeRoot(COUNT44_tree, root_1); @@ -2774,7 +2774,7 @@ Match(input, Token.DOWN, null); - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:12: ( DISTINCT | ALL )? + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:182:12: ( DISTINCT | ALL )? int alt19 = 2; int LA19_0 = input.LA(1); @@ -2811,7 +2811,7 @@ } - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:32: ( aggregateExpr | ROW_STAR ) + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:182:32: ( aggregateExpr | ROW_STAR ) int alt20 = 2; int LA20_0 = input.LA(1); @@ -2833,10 +2833,10 @@ switch (alt20) { case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:181:34: aggregateExpr + // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g:182:34: aggregateExpr { _last = (IASTNode)input.LT(1); - PushFollow(FOLLOW_aggregateExpr_in_count869); + PushFollow(FOLLOW_aggregateExpr_in_count874); aggregateExpr46 = aggregateExpr(); state.followingStackPointer--; @@ -2845,10 +2845,10 @@ } break; case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\HqlSqlWalker.g... [truncated message content] |
From: <fab...@us...> - 2009-05-07 03:34:47
|
Revision: 4257 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4257&view=rev Author: fabiomaulo Date: 2009-05-07 03:34:37 +0000 (Thu, 07 May 2009) Log Message: ----------- Fix NH-1765 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs trunk/nhibernate/src/NHibernate/Event/PreDeleteEvent.cs trunk/nhibernate/src/NHibernate/Event/PreInsertEvent.cs trunk/nhibernate/src/NHibernate/Event/PreUpdateEvent.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs Modified: trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -117,7 +117,7 @@ bool veto = false; if (preListeners.Length > 0) { - PreDeleteEvent preEvent = new PreDeleteEvent(Instance, Id, state, Persister); + var preEvent = new PreDeleteEvent(Instance, Id, state, Persister, (IEventSource)Session); foreach (IPreDeleteEventListener listener in preListeners) { veto |= listener.OnPreDelete(preEvent); Modified: trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -121,7 +121,7 @@ IPostInsertEventListener[] postListeners = Session.Listeners.PostCommitInsertEventListeners; if (postListeners.Length > 0) { - PostInsertEvent postEvent = new PostInsertEvent(Instance, generatedId, state, Persister, (IEventSource)Session); + var postEvent = new PostInsertEvent(Instance, generatedId, state, Persister, (IEventSource) Session); foreach (IPostInsertEventListener listener in postListeners) { listener.OnPostInsert(postEvent); @@ -135,7 +135,7 @@ bool veto = false; if (preListeners.Length > 0) { - PreInsertEvent preEvent = new PreInsertEvent(Instance, null, state, Persister, Session); + var preEvent = new PreInsertEvent(Instance, null, state, Persister, (IEventSource) Session); foreach (IPreInsertEventListener listener in preListeners) { veto |= listener.OnPreInsert(preEvent); @@ -144,7 +144,7 @@ return veto; } - //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!! + //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!! public override void AfterTransactionCompletion(bool success) { //TODO from H3.2: reenable if we also fix the above todo Modified: trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -154,7 +154,7 @@ bool veto = false; if (preListeners.Length > 0) { - PreInsertEvent preEvent = new PreInsertEvent(Instance, Id, state, Persister, Session); + var preEvent = new PreInsertEvent(Instance, Id, state, Persister, (IEventSource) Session); foreach (IPreInsertEventListener listener in preListeners) { veto |= listener.OnPreInsert(preEvent); Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -193,7 +193,7 @@ bool veto = false; if (preListeners.Length > 0) { - PreUpdateEvent preEvent = new PreUpdateEvent(Instance, Id, state, previousState, Persister, Session); + var preEvent = new PreUpdateEvent(Instance, Id, state, previousState, Persister, (IEventSource) Session); foreach (IPreUpdateEventListener listener in preListeners) { veto |= listener.OnPreUpdate(preEvent); Modified: trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -8,24 +8,19 @@ [Serializable] public class AbstractEvent { - private readonly IEventSource session; - /// <summary> /// Constructs an event from the given event session. /// </summary> /// <param name="source">The session event source. </param> public AbstractEvent(IEventSource source) { - session = source; + Session = source; } /// <summary> /// Returns the session event source for this event. /// This is the underlying session from which this event was generated. /// </summary> - public IEventSource Session - { - get { return session; } - } + public IEventSource Session { get; private set; } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -0,0 +1,43 @@ +using System; +using NHibernate.Engine; +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + /// <summary> + /// Represents an operation we are about to perform against the database. + /// </summary> + [Serializable] + public abstract class AbstractPreDatabaseOperationEvent : AbstractEvent + { + /// <summary> Constructs an event containing the pertinent information. </summary> + /// <param name="source">The session from which the event originated. </param> + /// <param name="entity">The entity to be invloved in the database operation. </param> + /// <param name="id">The entity id to be invloved in the database operation. </param> + /// <param name="persister">The entity's persister. </param> + protected AbstractPreDatabaseOperationEvent(IEventSource source, object entity, object id, IEntityPersister persister) + : base(source) + { + Entity = entity; + Id = id; + Persister = persister; + } + + /// <summary> The entity involved in the database operation. </summary> + public object Entity { get; private set; } + + /// <summary> The id to be used in the database operation. </summary> + public object Id { get; private set; } + + /// <summary> + /// The persister for the <see cref="Entity">. + /// </summary> + public IEntityPersister Persister { get; private set; } + + [Obsolete("Use Session property instead")] + public ISessionImplementor Source + { + get { return Session; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Event/PreDeleteEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PreDeleteEvent.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Event/PreDeleteEvent.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -3,41 +3,29 @@ namespace NHibernate.Event { /// <summary> - /// Occurs before deleting an item from the datastore + /// Represents a <tt>pre-delete</tt> event, which occurs just prior to + /// performing the deletion of an entity from the database. /// </summary> - public class PreDeleteEvent + public class PreDeleteEvent : AbstractPreDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] deletedState; - private readonly IEntityPersister persister; - - public PreDeleteEvent(object entity, object id, object[] deletedState, IEntityPersister persister) + /// <summary> + /// Constructs an event containing the pertinent information. + /// </summary> + /// <param name="entity">The entity to be deleted. </param> + /// <param name="id">The id to use in the deletion. </param> + /// <param name="deletedState">The entity's state at deletion time. </param> + /// <param name="persister">The entity's persister. </param> + /// <param name="source">The session from which the event originated. </param> + public PreDeleteEvent(object entity, object id, object[] deletedState, IEntityPersister persister, IEventSource source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.deletedState = deletedState; - this.persister = persister; + DeletedState = deletedState; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public object[] DeletedState - { - get { return deletedState; } - } - - public IEntityPersister Persister - { - get { return persister; } - } + /// <summary> + /// This is the entity state at the + /// time of deletion (useful for optomistic locking and such). + /// </summary> + public object[] DeletedState { get; private set; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Event/PreInsertEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PreInsertEvent.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Event/PreInsertEvent.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -1,51 +1,22 @@ -using NHibernate.Engine; using NHibernate.Persister.Entity; namespace NHibernate.Event { /// <summary> - /// Occurs before inserting an item in the datastore + /// Represents a <tt>pre-insert</tt> event, which occurs just prior to + /// performing the insert of an entity into the database. /// </summary> - public class PreInsertEvent + public class PreInsertEvent : AbstractPreDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly IEntityPersister persister; - private readonly ISessionImplementor source; - - public PreInsertEvent(object entity, object id, object[] state, IEntityPersister persister, ISessionImplementor source) + public PreInsertEvent(object entity, object id, object[] state, IEntityPersister persister, IEventSource source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.persister = persister; - this.source = source; + State = state; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public IEntityPersister Persister - { - get { return persister; } - } - - public ISessionImplementor Source - { - get { return source; } - } + /// <summary> + /// These are the values to be inserted. + /// </summary> + public object[] State { get; private set; } } } Modified: trunk/nhibernate/src/NHibernate/Event/PreUpdateEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PreUpdateEvent.cs 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/Event/PreUpdateEvent.cs 2009-05-07 03:34:37 UTC (rev 4257) @@ -1,62 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NHibernate.Engine; using NHibernate.Persister.Entity; namespace NHibernate.Event { /// <summary> - /// Occurs before updating the datastore + /// Represents a <tt>pre-update</tt> event, which occurs just prior to + /// performing the update of an entity in the database. /// </summary> - public class PreUpdateEvent + public class PreUpdateEvent : AbstractPreDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly object[] oldState; - private readonly IEntityPersister persister; - private readonly ISessionImplementor source; - - public PreUpdateEvent(object entity, object id, object[] state, object[] oldState, - IEntityPersister persister, ISessionImplementor source) + public PreUpdateEvent(object entity, object id, object[] state, object[] oldState, IEntityPersister persister, + IEventSource source) : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.oldState = oldState; - this.persister = persister; - this.source = source; + State = state; + OldState = oldState; } - public object Entity - { - get { return entity; } - } + /// <summary> + /// Retrieves the state to be used in the update. + /// </summary> + public object[] State { get; private set; } - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public object[] OldState - { - get { return oldState; } - } - - public IEntityPersister Persister - { - get { return persister; } - } - - public ISessionImplementor Source - { - get { return source; } - } + /// <summary> + /// The old state of the entity at the time it was last loaded from the + /// database; can be null in the case of detached entities. + /// </summary> + public object[] OldState { get; private set; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-06 22:59:51 UTC (rev 4256) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-07 03:34:37 UTC (rev 4257) @@ -471,6 +471,7 @@ <Compile Include="Driver\IfxDriver.cs" /> <Compile Include="Driver\OracleLiteDataClientDriver.cs" /> <Compile Include="EntityModeEqualityComparer.cs" /> + <Compile Include="Event\AbstractPreDatabaseOperationEvent.cs" /> <Compile Include="Event\IDestructible.cs" /> <Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" /> <Compile Include="Exceptions\SqlStateExtracter.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-07 10:41:11
|
Revision: 4260 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4260&view=rev Author: steverstrong Date: 2009-05-07 10:40:59 +0000 (Thu, 07 May 2009) Log Message: ----------- Fix for test HQL.Ast.BulkManipulation.SimpleInsert Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.g trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs 2009-05-07 05:49:01 UTC (rev 4259) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs 2009-05-07 10:40:59 UTC (rev 4260) @@ -1,6321 +1,6363 @@ -// $ANTLR 3.1.2 C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g 2009-05-05 16:13:08 - -// 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 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; - -using IDictionary = System.Collections.IDictionary; -using Hashtable = System.Collections.Hashtable; - -/** - * SQL Generator Tree Parser, providing SQL rendering of SQL ASTs produced by the previous phase, HqlSqlWalker. All - * syntax decoration such as extra spaces, lack of spaces, extra parens, etc. should be added by this class. - * <br> - * This grammar processes the HQL/SQL AST and produces an SQL string. The intent is to move dialect-specific - * code into a sub-class that will override some of the methods, just like the other two grammars in this system. - * @author Joshua Davis (jo...@hi...) - */ -public partial class SqlGenerator : 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 EXPONENT = 123; - public const int LT = 104; - 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 WEIRD_IDENT = 91; - public const int ESCqs = 121; - public const int OPEN_BRACKET = 113; - public const int FULL = 23; - public const int ORDER_ELEMENT = 83; - public const int INSERT = 29; - public const int ESCAPE = 18; - public const int IS_NULL = 78; - 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 EQ = 99; - public const int VERSIONED = 52; - public const int SELECT = 45; - public const int INTO = 30; - public const int NE = 102; - public const int GE = 107; - public const int ID_LETTER = 120; - public const int CONCAT = 108; - 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 THEN = 58; - public const int IN = 26; - public const int OBJECT = 66; - public const int COMMA = 98; - public const int IS = 31; - public const int SQL_TOKEN = 136; - public const int AVG = 9; - public const int LEFT = 33; - public const int SOME = 47; - public const int ALL = 4; - public const int IMPLIED_FROM = 129; - public const int IDENT = 118; - public const int PLUS = 109; - public const int CASE2 = 72; - public const int EXISTS = 19; - public const int DOT = 15; - public const int LIKE = 34; - public const int WITH = 61; - 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 HEX_DIGIT = 125; - public const int NOT_BETWEEN = 80; - public const int RANGE = 85; - public const int RIGHT_OUTER = 133; - public const int RIGHT = 44; - public const int SET = 46; - public const int HAVING = 25; - public const int MIN = 36; - public const int MINUS = 110; - public const int IS_NOT_NULL = 77; - public const int ELEMENTS = 17; - public const int TRUE = 49; - public const int JOIN = 32; - public const int UNION = 50; - public const int IN_LIST = 75; - public const int COLON = 115; - public const int OPEN = 100; - 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 BETWEEN = 10; - public const int AGGREGATE = 69; - public const int LE = 106; - - // delegates - // delegators - - - - public SqlGenerator(ITreeNodeStream input) - : this(input, new RecognizerSharedState()) { - } - - public SqlGenerator(ITreeNodeStream input, RecognizerSharedState state) - : base(input, state) { - InitializeCyclicDFAs(); - - - } - - - override public string[] TokenNames { - get { return SqlGenerator.tokenNames; } - } - - override public string GrammarFileName { - get { return "C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g"; } - } - - - - // $ANTLR start "statement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:27:1: statement : ( selectStatement | updateStatement | deleteStatement | insertStatement ); - public void statement() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:28:2: ( selectStatement | updateStatement | deleteStatement | insertStatement ) - int alt1 = 4; - switch ( input.LA(1) ) - { - case SELECT: - { - alt1 = 1; - } - break; - case UPDATE: - { - alt1 = 2; - } - break; - case DELETE: - { - alt1 = 3; - } - break; - case INSERT: - { - alt1 = 4; - } - break; - default: - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d1s0 = - new NoViableAltException("", 1, 0, input); - - throw nvae_d1s0; - } - - switch (alt1) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:28:4: selectStatement - { - PushFollow(FOLLOW_selectStatement_in_statement57); - selectStatement(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:29:4: updateStatement - { - PushFollow(FOLLOW_updateStatement_in_statement62); - updateStatement(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - case 3 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:30:4: deleteStatement - { - PushFollow(FOLLOW_deleteStatement_in_statement67); - deleteStatement(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - case 4 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:31:4: insertStatement - { - PushFollow(FOLLOW_insertStatement_in_statement72); - insertStatement(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "statement" - - - // $ANTLR start "selectStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:34:1: selectStatement : ^( SELECT selectClause from ( ^( WHERE whereExpr ) )? ( ^( GROUP groupExprs ( ^( HAVING booleanExpr[false] ) )? ) )? ( ^( ORDER orderExprs ) )? ) ; - public void selectStatement() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:35:2: ( ^( SELECT selectClause from ( ^( WHERE whereExpr ) )? ( ^( GROUP groupExprs ( ^( HAVING booleanExpr[false] ) )? ) )? ( ^( ORDER orderExprs ) )? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:35:4: ^( SELECT selectClause from ( ^( WHERE whereExpr ) )? ( ^( GROUP groupExprs ( ^( HAVING booleanExpr[false] ) )? ) )? ( ^( ORDER orderExprs ) )? ) - { - Match(input,SELECT,FOLLOW_SELECT_in_selectStatement84); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out("select "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_selectClause_in_selectStatement90); - selectClause(); - state.followingStackPointer--; - if (state.failed) return ; - PushFollow(FOLLOW_from_in_selectStatement94); - from(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:38:3: ( ^( WHERE whereExpr ) )? - int alt2 = 2; - int LA2_0 = input.LA(1); - - if ( (LA2_0 == WHERE) ) - { - alt2 = 1; - } - switch (alt2) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:38:5: ^( WHERE whereExpr ) - { - Match(input,WHERE,FOLLOW_WHERE_in_selectStatement101); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" where "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_whereExpr_in_selectStatement105); - whereExpr(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:39:3: ( ^( GROUP groupExprs ( ^( HAVING booleanExpr[false] ) )? ) )? - int alt4 = 2; - int LA4_0 = input.LA(1); - - if ( (LA4_0 == GROUP) ) - { - alt4 = 1; - } - switch (alt4) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:39:5: ^( GROUP groupExprs ( ^( HAVING booleanExpr[false] ) )? ) - { - Match(input,GROUP,FOLLOW_GROUP_in_selectStatement117); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" group by "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_groupExprs_in_selectStatement121); - groupExprs(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:39:47: ( ^( HAVING booleanExpr[false] ) )? - int alt3 = 2; - int LA3_0 = input.LA(1); - - if ( (LA3_0 == HAVING) ) - { - alt3 = 1; - } - switch (alt3) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:39:49: ^( HAVING booleanExpr[false] ) - { - Match(input,HAVING,FOLLOW_HAVING_in_selectStatement126); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" having "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_booleanExpr_in_selectStatement130); - booleanExpr(false); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - break; - - } - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:40:3: ( ^( ORDER orderExprs ) )? - int alt5 = 2; - int LA5_0 = input.LA(1); - - if ( (LA5_0 == ORDER) ) - { - alt5 = 1; - } - switch (alt5) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:40:5: ^( ORDER orderExprs ) - { - Match(input,ORDER,FOLLOW_ORDER_in_selectStatement147); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" order by "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_orderExprs_in_selectStatement151); - orderExprs(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - break; - - } - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "selectStatement" - - - // $ANTLR start "updateStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:47:1: updateStatement : ^( UPDATE ^( FROM fromTable ) setClause ( whereClause )? ) ; - public void updateStatement() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:48:2: ( ^( UPDATE ^( FROM fromTable ) setClause ( whereClause )? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:48:4: ^( UPDATE ^( FROM fromTable ) setClause ( whereClause )? ) - { - Match(input,UPDATE,FOLLOW_UPDATE_in_updateStatement174); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out("update "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - Match(input,FROM,FOLLOW_FROM_in_updateStatement182); if (state.failed) return ; - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_fromTable_in_updateStatement184); - fromTable(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - PushFollow(FOLLOW_setClause_in_updateStatement190); - setClause(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:51:3: ( whereClause )? - int alt6 = 2; - int LA6_0 = input.LA(1); - - if ( (LA6_0 == WHERE) ) - { - alt6 = 1; - } - switch (alt6) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:51:4: whereClause - { - PushFollow(FOLLOW_whereClause_in_updateStatement195); - whereClause(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "updateStatement" - - - // $ANTLR start "deleteStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:55:1: deleteStatement : ^( DELETE from ( whereClause )? ) ; - public void deleteStatement() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:57:2: ( ^( DELETE from ( whereClause )? ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:57:4: ^( DELETE from ( whereClause )? ) - { - Match(input,DELETE,FOLLOW_DELETE_in_deleteStatement214); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out("delete"); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_from_in_deleteStatement220); - from(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:59:3: ( whereClause )? - int alt7 = 2; - int LA7_0 = input.LA(1); - - if ( (LA7_0 == WHERE) ) - { - alt7 = 1; - } - switch (alt7) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:59:4: whereClause - { - PushFollow(FOLLOW_whereClause_in_deleteStatement225); - whereClause(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "deleteStatement" - - - // $ANTLR start "insertStatement" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:63:1: insertStatement : ^( INSERT i= INTO selectStatement ) ; - public void insertStatement() // throws RecognitionException [1] - { - IASTNode i = null; - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:64:2: ( ^( INSERT i= INTO selectStatement ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:64:4: ^( INSERT i= INTO selectStatement ) - { - Match(input,INSERT,FOLLOW_INSERT_in_insertStatement242); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out( "insert " ); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - i=(IASTNode)Match(input,INTO,FOLLOW_INTO_in_insertStatement250); if (state.failed) return ; - if ( (state.backtracking==0) ) - { - Out( i ); Out( " " ); - } - PushFollow(FOLLOW_selectStatement_in_insertStatement256); - selectStatement(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "insertStatement" - - - // $ANTLR start "setClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:70:1: setClause : ^( SET comparisonExpr[false] ( comparisonExpr[false] )* ) ; - public void setClause() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:73:2: ( ^( SET comparisonExpr[false] ( comparisonExpr[false] )* ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:73:4: ^( SET comparisonExpr[false] ( comparisonExpr[false] )* ) - { - Match(input,SET,FOLLOW_SET_in_setClause276); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" set "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_comparisonExpr_in_setClause280); - comparisonExpr(false); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:73:51: ( comparisonExpr[false] )* - do - { - int alt8 = 2; - int LA8_0 = input.LA(1); - - if ( (LA8_0 == BETWEEN || LA8_0 == EXISTS || LA8_0 == IN || LA8_0 == LIKE || (LA8_0 >= IS_NOT_NULL && LA8_0 <= IS_NULL) || (LA8_0 >= NOT_BETWEEN && LA8_0 <= NOT_LIKE) || LA8_0 == EQ || LA8_0 == NE || (LA8_0 >= LT && LA8_0 <= GE)) ) - { - alt8 = 1; - } - - - switch (alt8) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:73:53: comparisonExpr[false] - { - if ( (state.backtracking==0) ) - { - Out(", "); - } - PushFollow(FOLLOW_comparisonExpr_in_setClause287); - comparisonExpr(false); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - default: - goto loop8; - } - } while (true); - - loop8: - ; // Stops C# compiler whining that label 'loop8' has no statements - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "setClause" - - - // $ANTLR start "whereClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:76:1: whereClause : ^( WHERE whereClauseExpr ) ; - public void whereClause() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:77:2: ( ^( WHERE whereClauseExpr ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:77:4: ^( WHERE whereClauseExpr ) - { - Match(input,WHERE,FOLLOW_WHERE_in_whereClause305); if (state.failed) return ; - - if ( (state.backtracking==0) ) - { - Out(" where "); - } - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_whereClauseExpr_in_whereClause309); - whereClauseExpr(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "whereClause" - - - // $ANTLR start "whereClauseExpr" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:80:1: whereClauseExpr : ( ( SQL_TOKEN )=> conditionList | booleanExpr[ false ] ); - public void whereClauseExpr() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:81:2: ( ( SQL_TOKEN )=> conditionList | booleanExpr[ false ] ) - int alt9 = 2; - int LA9_0 = input.LA(1); - - if ( (LA9_0 == SQL_TOKEN) ) - { - int LA9_1 = input.LA(2); - - if ( (LA9_1 == DOWN) && (synpred1_SqlGenerator()) ) - { - alt9 = 1; - } - else if ( (LA9_1 == UP) ) - { - alt9 = 2; - } - else - { - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d9s1 = - new NoViableAltException("", 9, 1, input); - - throw nvae_d9s1; - } - } - else if ( (LA9_0 == AND || LA9_0 == BETWEEN || LA9_0 == EXISTS || LA9_0 == IN || LA9_0 == LIKE || LA9_0 == NOT || LA9_0 == OR || (LA9_0 >= IS_NOT_NULL && LA9_0 <= IS_NULL) || (LA9_0 >= NOT_BETWEEN && LA9_0 <= NOT_LIKE) || LA9_0 == EQ || LA9_0 == NE || (LA9_0 >= LT && LA9_0 <= GE)) ) - { - alt9 = 2; - } - else - { - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d9s0 = - new NoViableAltException("", 9, 0, input); - - throw nvae_d9s0; - } - switch (alt9) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:81:4: ( SQL_TOKEN )=> conditionList - { - PushFollow(FOLLOW_conditionList_in_whereClauseExpr328); - conditionList(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:82:4: booleanExpr[ false ] - { - PushFollow(FOLLOW_booleanExpr_in_whereClauseExpr333); - booleanExpr(false); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "whereClauseExpr" - - - // $ANTLR start "orderExprs" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:85:1: orderExprs : ( expr ) (dir= orderDirection )? ( orderExprs )? ; - public void orderExprs() // throws RecognitionException [1] - { - SqlGenerator.orderDirection_return dir = default(SqlGenerator.orderDirection_return); - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:2: ( ( expr ) (dir= orderDirection )? ( orderExprs )? ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:4: ( expr ) (dir= orderDirection )? ( orderExprs )? - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:4: ( expr ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:6: expr - { - PushFollow(FOLLOW_expr_in_orderExprs349); - expr(); - state.followingStackPointer--; - if (state.failed) return ; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:13: (dir= orderDirection )? - int alt10 = 2; - int LA10_0 = input.LA(1); - - if ( (LA10_0 == ASCENDING || LA10_0 == DESCENDING) ) - { - alt10 = 1; - } - switch (alt10) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:14: dir= orderDirection - { - PushFollow(FOLLOW_orderDirection_in_orderExprs356); - dir = orderDirection(); - state.followingStackPointer--; - if (state.failed) return ; - if ( (state.backtracking==0) ) - { - Out(" "); Out(((dir != null) ? ((IASTNode)dir.Start) : null)); - } - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:66: ( orderExprs )? - int alt11 = 2; - int LA11_0 = input.LA(1); - - if ( ((LA11_0 >= ALL && LA11_0 <= ANY) || LA11_0 == COUNT || LA11_0 == DOT || LA11_0 == FALSE || LA11_0 == NULL || LA11_0 == SELECT || LA11_0 == SOME || LA11_0 == TRUE || LA11_0 == CASE || LA11_0 == AGGREGATE || LA11_0 == CASE2 || LA11_0 == INDEX_OP || LA11_0 == METHOD_CALL || LA11_0 == UNARY_MINUS || LA11_0 == VECTOR_EXPR || (LA11_0 >= CONSTANT && LA11_0 <= JAVA_CONSTANT) || (LA11_0 >= PLUS && LA11_0 <= DIV) || (LA11_0 >= PARAM && LA11_0 <= IDENT) || LA11_0 == ALIAS_REF || LA11_0 == SQL_TOKEN || LA11_0 == NAMED_PARAM) ) - { - alt11 = 1; - } - switch (alt11) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:87:68: orderExprs - { - if ( (state.backtracking==0) ) - { - Out(", "); - } - PushFollow(FOLLOW_orderExprs_in_orderExprs366); - orderExprs(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "orderExprs" - - - // $ANTLR start "groupExprs" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:90:1: groupExprs : expr ( groupExprs )? ; - public void groupExprs() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:92:2: ( expr ( groupExprs )? ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:92:4: expr ( groupExprs )? - { - PushFollow(FOLLOW_expr_in_groupExprs381); - expr(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:92:9: ( groupExprs )? - int alt12 = 2; - int LA12_0 = input.LA(1); - - if ( ((LA12_0 >= ALL && LA12_0 <= ANY) || LA12_0 == COUNT || LA12_0 == DOT || LA12_0 == FALSE || LA12_0 == NULL || LA12_0 == SELECT || LA12_0 == SOME || LA12_0 == TRUE || LA12_0 == CASE || LA12_0 == AGGREGATE || LA12_0 == CASE2 || LA12_0 == INDEX_OP || LA12_0 == METHOD_CALL || LA12_0 == UNARY_MINUS || LA12_0 == VECTOR_EXPR || (LA12_0 >= CONSTANT && LA12_0 <= JAVA_CONSTANT) || (LA12_0 >= PLUS && LA12_0 <= DIV) || (LA12_0 >= PARAM && LA12_0 <= IDENT) || LA12_0 == ALIAS_REF || LA12_0 == SQL_TOKEN || LA12_0 == NAMED_PARAM) ) - { - alt12 = 1; - } - switch (alt12) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:92:11: groupExprs - { - if ( (state.backtracking==0) ) - { - Out(" , "); - } - PushFollow(FOLLOW_groupExprs_in_groupExprs387); - groupExprs(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "groupExprs" - - public class orderDirection_return : TreeRuleReturnScope - { - }; - - // $ANTLR start "orderDirection" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:95:1: orderDirection : ( ASCENDING | DESCENDING ); - public SqlGenerator.orderDirection_return orderDirection() // throws RecognitionException [1] - { - SqlGenerator.orderDirection_return retval = new SqlGenerator.orderDirection_return(); - retval.Start = input.LT(1); - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:96:2: ( ASCENDING | DESCENDING ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g: - { - if ( input.LA(1) == ASCENDING || input.LA(1) == DESCENDING ) - { - input.Consume(); - state.errorRecovery = false;state.failed = false; - } - else - { - if ( state.backtracking > 0 ) {state.failed = true; return retval;} - MismatchedSetException mse = new MismatchedSetException(null,input); - throw mse; - } - - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return retval; - } - // $ANTLR end "orderDirection" - - - // $ANTLR start "whereExpr" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:100:1: whereExpr : ( filters ( thetaJoins )? ( booleanExpr[ true ] )? | thetaJoins ( booleanExpr[ true ] )? | booleanExpr[false] ); - public void whereExpr() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:104:2: ( filters ( thetaJoins )? ( booleanExpr[ true ] )? | thetaJoins ( booleanExpr[ true ] )? | booleanExpr[false] ) - int alt16 = 3; - switch ( input.LA(1) ) - { - case FILTERS: - { - alt16 = 1; - } - break; - case THETA_JOINS: - { - alt16 = 2; - } - break; - case AND: - case BETWEEN: - case EXISTS: - case IN: - case LIKE: - case NOT: - case OR: - case IS_NOT_NULL: - case IS_NULL: - case NOT_BETWEEN: - case NOT_IN: - case NOT_LIKE: - case EQ: - case NE: - case LT: - case GT: - case LE: - case GE: - case SQL_TOKEN: - { - alt16 = 3; - } - break; - default: - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d16s0 = - new NoViableAltException("", 16, 0, input); - - throw nvae_d16s0; - } - - switch (alt16) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:104:4: filters ( thetaJoins )? ( booleanExpr[ true ] )? - { - PushFollow(FOLLOW_filters_in_whereExpr422); - filters(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:105:3: ( thetaJoins )? - int alt13 = 2; - int LA13_0 = input.LA(1); - - if ( (LA13_0 == THETA_JOINS) ) - { - alt13 = 1; - } - switch (alt13) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:105:5: thetaJoins - { - if ( (state.backtracking==0) ) - { - Out(" and "); - } - PushFollow(FOLLOW_thetaJoins_in_whereExpr430); - thetaJoins(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:106:3: ( booleanExpr[ true ] )? - int alt14 = 2; - int LA14_0 = input.LA(1); - - if ( (LA14_0 == AND || LA14_0 == BETWEEN || LA14_0 == EXISTS || LA14_0 == IN || LA14_0 == LIKE || LA14_0 == NOT || LA14_0 == OR || (LA14_0 >= IS_NOT_NULL && LA14_0 <= IS_NULL) || (LA14_0 >= NOT_BETWEEN && LA14_0 <= NOT_LIKE) || LA14_0 == EQ || LA14_0 == NE || (LA14_0 >= LT && LA14_0 <= GE) || LA14_0 == SQL_TOKEN) ) - { - alt14 = 1; - } - switch (alt14) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:106:5: booleanExpr[ true ] - { - if ( (state.backtracking==0) ) - { - Out(" and "); - } - PushFollow(FOLLOW_booleanExpr_in_whereExpr441); - booleanExpr(true); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:107:4: thetaJoins ( booleanExpr[ true ] )? - { - PushFollow(FOLLOW_thetaJoins_in_whereExpr451); - thetaJoins(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:108:3: ( booleanExpr[ true ] )? - int alt15 = 2; - int LA15_0 = input.LA(1); - - if ( (LA15_0 == AND || LA15_0 == BETWEEN || LA15_0 == EXISTS || LA15_0 == IN || LA15_0 == LIKE || LA15_0 == NOT || LA15_0 == OR || (LA15_0 >= IS_NOT_NULL && LA15_0 <= IS_NULL) || (LA15_0 >= NOT_BETWEEN && LA15_0 <= NOT_LIKE) || LA15_0 == EQ || LA15_0 == NE || (LA15_0 >= LT && LA15_0 <= GE) || LA15_0 == SQL_TOKEN) ) - { - alt15 = 1; - } - switch (alt15) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:108:5: booleanExpr[ true ] - { - if ( (state.backtracking==0) ) - { - Out(" and "); - } - PushFollow(FOLLOW_booleanExpr_in_whereExpr459); - booleanExpr(true); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - } - break; - case 3 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:109:4: booleanExpr[false] - { - PushFollow(FOLLOW_booleanExpr_in_whereExpr470); - booleanExpr(false); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "whereExpr" - - - // $ANTLR start "filters" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:112:1: filters : ^( FILTERS conditionList ) ; - public void filters() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:113:2: ( ^( FILTERS conditionList ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:113:4: ^( FILTERS conditionList ) - { - Match(input,FILTERS,FOLLOW_FILTERS_in_filters483); if (state.failed) return ; - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_conditionList_in_filters485); - conditionList(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "filters" - - - // $ANTLR start "thetaJoins" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:116:1: thetaJoins : ^( THETA_JOINS conditionList ) ; - public void thetaJoins() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:117:2: ( ^( THETA_JOINS conditionList ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:117:4: ^( THETA_JOINS conditionList ) - { - Match(input,THETA_JOINS,FOLLOW_THETA_JOINS_in_thetaJoins499); if (state.failed) return ; - - Match(input, Token.DOWN, null); if (state.failed) return ; - PushFollow(FOLLOW_conditionList_in_thetaJoins501); - conditionList(); - state.followingStackPointer--; - if (state.failed) return ; - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "thetaJoins" - - - // $ANTLR start "conditionList" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:120:1: conditionList : sqlToken ( conditionList )? ; - public void conditionList() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:121:2: ( sqlToken ( conditionList )? ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:121:4: sqlToken ( conditionList )? - { - PushFollow(FOLLOW_sqlToken_in_conditionList514); - sqlToken(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:121:13: ( conditionList )? - int alt17 = 2; - int LA17_0 = input.LA(1); - - if ( (LA17_0 == SQL_TOKEN) ) - { - alt17 = 1; - } - switch (alt17) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:121:15: conditionList - { - if ( (state.backtracking==0) ) - { - Out(" and "); - } - PushFollow(FOLLOW_conditionList_in_conditionList520); - conditionList(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "conditionList" - - - // $ANTLR start "selectClause" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:124:1: selectClause : ^( SELECT_CLAUSE ( distinctOrAll )? ( selectColumn )+ ) ; - public void selectClause() // throws RecognitionException [1] - { - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:2: ( ^( SELECT_CLAUSE ( distinctOrAll )? ( selectColumn )+ ) ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:4: ^( SELECT_CLAUSE ( distinctOrAll )? ( selectColumn )+ ) - { - Match(input,SELECT_CLAUSE,FOLLOW_SELECT_CLAUSE_in_selectClause535); if (state.failed) return ; - - Match(input, Token.DOWN, null); if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:20: ( distinctOrAll )? - int alt18 = 2; - int LA18_0 = input.LA(1); - - if ( (LA18_0 == ALL || LA18_0 == DISTINCT) ) - { - alt18 = 1; - } - switch (alt18) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:21: distinctOrAll - { - PushFollow(FOLLOW_distinctOrAll_in_selectClause538); - distinctOrAll(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - } - - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:37: ( selectColumn )+ - int cnt19 = 0; - do - { - int alt19 = 2; - int LA19_0 = input.LA(1); - - if ( (LA19_0 == COUNT || LA19_0 == DOT || LA19_0 == FALSE || LA19_0 == SELECT || LA19_0 == TRUE || LA19_0 == CASE || LA19_0 == AGGREGATE || (LA19_0 >= CONSTRUCTOR && LA19_0 <= CASE2) || LA19_0 == METHOD_CALL || LA19_0 == UNARY_MINUS || (LA19_0 >= CONSTANT && LA19_0 <= JAVA_CONSTANT) || (LA19_0 >= PLUS && LA19_0 <= DIV) || (LA19_0 >= PARAM && LA19_0 <= IDENT) || LA19_0 == ALIAS_REF || LA19_0 == SQL_TOKEN || LA19_0 == SELECT_EXPR) ) - { - alt19 = 1; - } - - - switch (alt19) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:125:39: selectColumn - { - PushFollow(FOLLOW_selectColumn_in_selectClause544); - selectColumn(); - state.followingStackPointer--; - if (state.failed) return ; - - } - break; - - default: - if ( cnt19 >= 1 ) goto loop19; - if ( state.backtracking > 0 ) {state.failed = true; return ;} - EarlyExitException eee19 = - new EarlyExitException(19, input); - throw eee19; - } - cnt19++; - } while (true); - - loop19: - ; // Stops C# compiler whinging that label 'loop19' has no statements - - - Match(input, Token.UP, null); if (state.failed) return ; - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "selectClause" - - - // $ANTLR start "selectColumn" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:128:1: selectColumn : p= selectExpr (sc= SELECT_COLUMNS )? ; - public void selectColumn() // throws RecognitionException [1] - { - IASTNode sc = null; - SqlGenerator.selectExpr_return p = default(SqlGenerator.selectExpr_return); - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:129:2: (p= selectExpr (sc= SELECT_COLUMNS )? ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:129:4: p= selectExpr (sc= SELECT_COLUMNS )? - { - PushFollow(FOLLOW_selectExpr_in_selectColumn562); - p = selectExpr(); - state.followingStackPointer--; - if (state.failed) return ; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:129:17: (sc= SELECT_COLUMNS )? - int alt20 = 2; - int LA20_0 = input.LA(1); - - if ( (LA20_0 == SELECT_COLUMNS) ) - { - alt20 = 1; - } - switch (alt20) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:129:18: sc= SELECT_COLUMNS - { - sc=(IASTNode)Match(input,SELECT_COLUMNS,FOLLOW_SELECT_COLUMNS_in_selectColumn567); if (state.failed) return ; - if ( (state.backtracking==0) ) - { - Out(sc); - } - - } - break; - - } - - if ( (state.backtracking==0) ) - { - Separator( (sc != null) ? sc : ((p != null) ? ((IASTNode)p.Start) : null) ,", "); - } - - } - - } - catch (RecognitionException re) - { - ReportError(re); - Recover(input,re); - } - finally - { - } - return ; - } - // $ANTLR end "selectColumn" - - public class selectExpr_return : TreeRuleReturnScope - { - }; - - // $ANTLR start "selectExpr" - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:132:1: selectExpr : (e= selectAtom | count | ^( CONSTRUCTOR ( DOT | IDENT ) ( selectColumn )+ ) | methodCall | aggregate | c= constant | arithmeticExpr | param= PARAM | selectStatement ); - public SqlGenerator.selectExpr_return selectExpr() // throws RecognitionException [1] - { - SqlGenerator.selectExpr_return retval = new SqlGenerator.selectExpr_return(); - retval.Start = input.LT(1); - - IASTNode param = null; - SqlGenerator.selectAtom_return e = default(SqlGenerator.selectAtom_return); - - SqlGenerator.constant_return c = default(SqlGenerator.constant_return); - - - try - { - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\SqlGenerator.g:133:2: (e= selectAtom | count | ^( CONSTRUCTOR ( DOT | IDENT ) ( selectColumn )+ ) | methodCall | aggregate | c= constant | arithmeticExpr | param= PARAM | selectStatement ) - int alt22 = 9; - switch ( input.LA(1) ) - { - case DOT: - case ALIAS_REF: - case SQL_TOKEN: - case SELE... [truncated message content] |
From: <fab...@us...> - 2009-05-07 18:00:53
|
Revision: 4262 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4262&view=rev Author: fabiomaulo Date: 2009-05-07 18:00:44 +0000 (Thu, 07 May 2009) Log Message: ----------- - Minor adjust of exceptions - Test for "with" clause Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/InvalidWithClauseException.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs trunk/nhibernate/src/NHibernate/QueryException.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/InvalidWithClauseException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/InvalidWithClauseException.cs 2009-05-07 15:04:34 UTC (rev 4261) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/InvalidWithClauseException.cs 2009-05-07 18:00:44 UTC (rev 4262) @@ -1,13 +1,16 @@ -namespace NHibernate.Hql.Ast.ANTLR +using System; +using System.Runtime.Serialization; + +namespace NHibernate.Hql.Ast.ANTLR { - class InvalidWithClauseException : QuerySyntaxException + [CLSCompliant(false)] + [Serializable] + public class InvalidWithClauseException : QuerySyntaxException { - public InvalidWithClauseException(string message) : base(message) - { - } + protected InvalidWithClauseException() {} + public InvalidWithClauseException(string message) : base(message) {} + public InvalidWithClauseException(string message, Exception inner) : base(message, inner) {} - public InvalidWithClauseException(string message, string hql) : base(message, hql) - { - } + protected InvalidWithClauseException(SerializationInfo info, StreamingContext context) : base(info, context) {} } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-05-07 15:04:34 UTC (rev 4261) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-05-07 18:00:44 UTC (rev 4262) @@ -1,20 +1,21 @@ using System; +using System.Runtime.Serialization; using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { [CLSCompliant(false)] + [Serializable] public class QuerySyntaxException : QueryException { - public QuerySyntaxException(string message) : base(message) - { - } + protected QuerySyntaxException() {} + public QuerySyntaxException(string message, string hql) : base(message, hql) {} - public QuerySyntaxException(string message, string hql) - : base(message, hql) - { - } + public QuerySyntaxException(string message) : base(message) {} + public QuerySyntaxException(string message, Exception inner) : base(message, inner) {} + protected QuerySyntaxException(SerializationInfo info, StreamingContext context) : base(info, context) {} + public static QuerySyntaxException Convert(RecognitionException e) { return Convert(e, null); @@ -23,9 +24,9 @@ public static QuerySyntaxException Convert(RecognitionException e, string hql) { string positionInfo = e.Line > 0 && e.CharPositionInLine > 0 - ? " near line " + e.Line + ", column " + e.CharPositionInLine - : ""; + ? " near line " + e.Line + ", column " + e.CharPositionInLine + : ""; return new QuerySyntaxException(e.Message + positionInfo, hql); } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/QueryException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/QueryException.cs 2009-05-07 15:04:34 UTC (rev 4261) +++ trunk/nhibernate/src/NHibernate/QueryException.cs 2009-05-07 18:00:44 UTC (rev 4262) @@ -12,6 +12,8 @@ { private string queryString; + protected QueryException() {} + /// <summary> /// Initializes a new instance of the <see cref="QueryException"/> class. /// </summary> Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/WithClauseFixture.cs 2009-05-07 18:00:44 UTC (rev 4262) @@ -0,0 +1,159 @@ +using System.Collections; +using NHibernate.Hql.Ast.ANTLR; +using NUnit.Framework; + +namespace NHibernate.Test.HQL.Ast +{ + [TestFixture, Ignore("Not suported yet.")] + public class WithClauseFixture : BaseFixture + { + public ISession OpenNewSession() + { + return OpenSession(); + } + + [Test] + public void WithClauseFailsWithFetch() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction txn = s.BeginTransaction(); + + Assert.Throws<HibernateException>( + () => + 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"); + + txn.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] + public void InvalidWithSemantics() + { + ISession s = OpenSession(); + ITransaction txn = s.BeginTransaction(); + + // PROBLEM : f.bodyWeight is a reference to a column on the Animal table; however, the 'f' + // alias relates to the Human.friends collection which the aonther Human entity. The issue + // here is the way JoinSequence and Joinable (the persister) interact to generate the + // joins relating to the sublcass/superclass tables + Assert.Throws<InvalidWithClauseException>( + () => + s.CreateQuery("from Human h inner join h.friends as f with f.bodyWeight < :someLimit").SetDouble("someLimit", 1). + List()); + + Assert.Throws<InvalidWithClauseException>( + () => + s.CreateQuery( + "from Animal a inner join a.offspring o inner join o.mother as m inner join m.father as f with o.bodyWeight > 1"). + List()); + + Assert.Throws<InvalidWithClauseException>( + () => + s.CreateQuery("from Human h inner join h.offspring o with o.mother.father = :cousin").SetEntity("cousin", + s.Load<Human>(123L)) + .List()); + + txn.Commit(); + s.Close(); + } + + [Test] + public void WithClause() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction txn = s.BeginTransaction(); + + // one-to-many + 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"); + + // many-to-one + list = + s.CreateQuery("from Animal a inner join a.mother as m with m.bodyWeight < :someLimit").SetDouble("someLimit", 1). + List(); + Assert.That(list, Is.Empty, "ad-hoc on did not take effect"); + + // many-to-many + list = s.CreateQuery("from Human h inner join h.friends as f with f.nickName like 'bubba'").List(); + Assert.That(list, Is.Empty, "ad-hoc on did not take effect"); + + txn.Commit(); + s.Close(); + + data.Cleanup(); + } + + private class TestData + { + private readonly WithClauseFixture tc; + + public TestData(WithClauseFixture tc) + { + this.tc = tc; + } + + public void Prepare() + { + ISession session = tc.OpenNewSession(); + ITransaction txn = session.BeginTransaction(); + + var mother = new Human {BodyWeight = 10, Description = "mother"}; + + var father = new Human {BodyWeight = 15, Description = "father"}; + + var child1 = new Human {BodyWeight = 5, Description = "child1"}; + + var child2 = new Human {BodyWeight = 6, Description = "child2"}; + + var friend = new Human {BodyWeight = 20, Description = "friend"}; + + child1.Mother = mother; + child1.Father = father; + mother.AddOffspring(child1); + father.AddOffspring(child1); + + child2.Mother = mother; + child2.Father = father; + mother.AddOffspring(child2); + father.AddOffspring(child2); + + father.Friends = new[] {friend}; + + session.Save(mother); + session.Save(father); + session.Save(child1); + session.Save(child2); + session.Save(friend); + + txn.Commit(); + session.Close(); + } + + public void Cleanup() + { + ISession session = tc.OpenNewSession(); + ITransaction txn = session.BeginTransaction(); + session.CreateQuery("delete Animal where mother is not null").ExecuteUpdate(); + IList humansWithFriends = session.CreateQuery("from Human h where exists(from h.friends)").List(); + foreach (var friend in humansWithFriends) + { + session.Delete(friend); + } + session.CreateQuery("delete Animal").ExecuteUpdate(); + txn.Commit(); + session.Close(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-07 15:04:34 UTC (rev 4261) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-07 18:00:44 UTC (rev 4262) @@ -322,6 +322,7 @@ <Compile Include="HQL\Ast\TimestampVersioned.cs" /> <Compile Include="HQL\Ast\User.cs" /> <Compile Include="HQL\Ast\Vehicles.cs" /> + <Compile Include="HQL\Ast\WithClauseFixture.cs" /> <Compile Include="HQL\Ast\Zoo.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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 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: <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-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: <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: <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: <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-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: <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: <fab...@us...> - 2009-05-13 22:32:16
|
Revision: 4294 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4294&view=rev Author: fabiomaulo Date: 2009-05-13 22:32:05 +0000 (Wed, 13 May 2009) Log Message: ----------- - Fix the problem created in the my previous commit. - Fixed SqlClientBatchingBatcher and now we have a test about it Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/LogSpy.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Ado/ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -19,7 +19,10 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - currentBatchCommandsLog = new StringBuilder(); + if (log.IsDebugEnabled) + { + currentBatchCommandsLog = new StringBuilder(); + } } public override int BatchSize @@ -32,20 +35,23 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.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) + else { log.Debug("Adding to batch:" + lineWithParameters); } + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } + else + { + Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { @@ -58,12 +64,9 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); + log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } int rowsAffected = currentBatch.ExecuteNonQuery(); Added: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,197 @@ +using System.Collections; +using NHibernate.AdoNet; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.Ado +{ + [TestFixture] + public class BatcherFixture: TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "Ado.VerySimple.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.FormatSql, "true"); + configuration.SetProperty(Environment.GenerateStatistics, "true"); + configuration.SetProperty(Environment.BatchSize, "10"); + } + + protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) + { + return !(factory.Settings.BatcherFactory is NonBatchingBatcherFactory); + } + + [Test] + [Description("The batcher should run all INSERT queries in only one roundtrip.")] + public void OneRoundTripInserts() + { + sessions.Statistics.Clear(); + FillDb(); + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + private void Cleanup() + { + using (ISession s = sessions.OpenSession()) + using (s.BeginTransaction()) + { + s.CreateQuery("delete from VerySimple").ExecuteUpdate(); + s.Transaction.Commit(); + } + } + + private void FillDb() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(new VerySimple {Id = 1, Name = "Fabio", Weight = 119.5}); + s.Save(new VerySimple {Id = 2, Name = "Fiamma", Weight = 9.8}); + tx.Commit(); + } + } + + [Test] + [Description("The batcher should run all UPDATE queries in only one roundtrip.")] + public void OneRoundTripUpdate() + { + FillDb(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + var vs1 = s.Get<VerySimple>(1); + var vs2 = s.Get<VerySimple>(2); + vs1.Weight -= 10; + vs1.Weight -= 1; + sessions.Statistics.Clear(); + s.Update(vs1); + s.Update(vs2); + tx.Commit(); + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description("The batcher should run all DELETE queries in only one roundtrip.")] + public void OneRoundTripDelete() + { + FillDb(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + var vs1 = s.Get<VerySimple>(1); + var vs2 = s.Get<VerySimple>(2); + sessions.Statistics.Clear(); + s.Delete(vs1); + s.Delete(vs2); + tx.Commit(); + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the SQL and turning off the batcher's log the log stream: +-should not contains any batch info +-should contain SQL's log info +-the batcher should work.")] + public void SqlLog() + { + using (new LogSpy(typeof(AbstractBatcher), true)) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + string logs = sl.GetWholeLog(); + Assert.That(logs, Text.DoesNotContain("batch").IgnoreCase); + Assert.That(logs, Text.Contains("INSERT").IgnoreCase); + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the AbstractBatcher's log the log stream: +-should not contains batch info +-should contain SQL log info only regarding batcher (SQL log should not be duplicated) +-the batcher should work.")] + public void AbstractBatcherLog() + { + using (new LogSpy(typeof(AbstractBatcher))) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + string logs = sl.GetWholeLog(); + Assert.That(logs, Text.Contains("batch").IgnoreCase); + foreach (var loggingEvent in sl.Appender.GetEvents()) + { + string message = loggingEvent.RenderedMessage; + if(message.ToLowerInvariant().Contains("insert")) + { + Assert.That(message, Text.Contains("batch").IgnoreCase); + } + } + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the AbstractBatcher's log the log stream: +-should contain well formatted SQL log info")] + public void AbstractBatcherLogFormattedSql() + { + using (new LogSpy(typeof(AbstractBatcher))) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + foreach (var loggingEvent in sl.Appender.GetEvents()) + { + string message = loggingEvent.RenderedMessage; + if(message.StartsWith("Adding")) + { + // should be the line with the formatted SQL + var strings = message.Split(System.Environment.NewLine.ToCharArray()); + foreach (var sqlLine in strings) + { + if(sqlLine.Contains("p0")) + { + Assert.That(sqlLine, Text.Contains("p1")); + Assert.That(sqlLine, Text.Contains("p2")); + } + } + } + } + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.Ado +{ + public class VerySimple + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual double Weight { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.Ado"> + + <class name="VerySimple"> + <id name="Id"/> + <property name="Name"/> + <property name="Weight"/> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/LogSpy.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using log4net; using log4net.Appender; using log4net.Core; @@ -12,7 +14,7 @@ private readonly Logger logger; private readonly Level prevLogLevel; - public LogSpy(ILog log) + public LogSpy(ILog log, bool disable) { logger = log.Logger as Logger; if (logger == null) @@ -22,22 +24,35 @@ // Change the log level to DEBUG and temporarily save the previous log level prevLogLevel = logger.Level; - logger.Level = Level.Debug; + logger.Level = disable ? Level.Off : Level.Debug; // Add a new MemoryAppender to the logger. appender = new MemoryAppender(); logger.AddAppender(appender); } - public LogSpy(System.Type loggerType) : this(LogManager.GetLogger(loggerType)) {} + public LogSpy(ILog log) : this(log, false) { } + public LogSpy(System.Type loggerType) : this(LogManager.GetLogger(loggerType), false) { } + public LogSpy(System.Type loggerType, bool disable) : this(LogManager.GetLogger(loggerType), disable) { } - public LogSpy(string loggerName) : this(LogManager.GetLogger(loggerName)) {} + public LogSpy(string loggerName) : this(LogManager.GetLogger(loggerName), false) { } + public LogSpy(string loggerName, bool disable) : this(LogManager.GetLogger(loggerName), disable) { } public MemoryAppender Appender { get { return appender; } } + public virtual string GetWholeLog() + { + var wholeMessage = new StringBuilder(); + foreach (LoggingEvent loggingEvent in Appender.GetEvents()) + { + wholeMessage.Append(loggingEvent.RenderedMessage); + } + return wholeMessage.ToString(); + } + #region IDisposable Members public void Dispose() Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 22:32:05 UTC (rev 4294) @@ -74,6 +74,8 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Ado\BatcherFixture.cs" /> + <Compile Include="Ado\VerySimple.cs" /> <Compile Include="Any\Address.cs" /> <Compile Include="Any\AnyTypeTest.cs" /> <Compile Include="Any\ComplexPropertyValue.cs" /> @@ -1769,6 +1771,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> + <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.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-13 23:07:17
|
Revision: 4295 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4295&view=rev Author: fabiomaulo Date: 2009-05-13 23:07:09 +0000 (Wed, 13 May 2009) Log Message: ----------- Fix NH-1767 (by James Kovacs) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-13 22:32:05 UTC (rev 4294) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-13 23:07:09 UTC (rev 4295) @@ -381,12 +381,16 @@ 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); - }; + { + bool wasSuccessful = e.Transaction.TransactionInformation.Status + == TransactionStatus.Committed; + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + { + Dispose(true); + } + ambientTransation = null; + }; ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); } } Modified: trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-13 22:32:05 UTC (rev 4294) +++ trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-13 23:07:09 UTC (rev 4295) @@ -14,23 +14,23 @@ public class RecordingInterceptor : EmptyInterceptor { - public bool afterTransactionBeginCalled; - public bool afterTransactionCompletionCalled; - public bool beforeTransactionCompletionCalled; + public int afterTransactionBeginCalled; + public int afterTransactionCompletionCalled; + public int beforeTransactionCompletionCalled; public override void AfterTransactionBegin(ITransaction tx) { - afterTransactionBeginCalled = true; + afterTransactionBeginCalled++; } public override void AfterTransactionCompletion(ITransaction tx) { - afterTransactionCompletionCalled = true; + afterTransactionCompletionCalled++; } public override void BeforeTransactionCompletion(ITransaction tx) { - beforeTransactionCompletionCalled = true; + beforeTransactionCompletionCalled++; } } @@ -40,9 +40,9 @@ RecordingInterceptor interceptor = new RecordingInterceptor(); using (sessions.OpenSession(interceptor)) { - Assert.IsFalse(interceptor.afterTransactionBeginCalled); - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsFalse(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionCompletionCalled); } } @@ -53,9 +53,9 @@ using (new TransactionScope()) using (sessions.OpenSession(interceptor)) { - Assert.IsTrue(interceptor.afterTransactionBeginCalled); - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsFalse(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionCompletionCalled); } } @@ -70,8 +70,8 @@ scope.Complete(); } session.Dispose(); - Assert.IsTrue(interceptor.beforeTransactionCompletionCalled); - Assert.IsTrue(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionCompletionCalled); } @@ -83,9 +83,41 @@ using (sessions.OpenSession(interceptor)) { } - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsTrue(interceptor.afterTransactionCompletionCalled); - + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(2, interceptor.afterTransactionCompletionCalled); } + + [Test] + public void TwoTransactionScopesInsideOneSession() { + var interceptor = new RecordingInterceptor(); + using(var session = sessions.OpenSession(interceptor)) { + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + } + Assert.AreEqual(2, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(2, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(2, interceptor.afterTransactionCompletionCalled); + } + + [Test] + public void OneTransactionScopesInsideOneSession() { + var interceptor = new RecordingInterceptor(); + using(var session = sessions.OpenSession(interceptor)) { + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + } + Assert.AreEqual(1, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(1, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionCompletionCalled); + } } } \ 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-14 06:41:15
|
Revision: 4298 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4298&view=rev Author: fabiomaulo Date: 2009-05-14 06:41:09 +0000 (Thu, 14 May 2009) Log Message: ----------- - Improved log to check Dtc possible problems - Fix NH-1769 (by Timo Rantanen) - added some test for Dtc Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -318,10 +318,13 @@ using (var tx = new TransactionScope(ambientTransation)) { BeforeTransactionCompletion(null); - if (FlushMode != FlushMode.Never) + if (FlushMode != FlushMode.Never && ConnectionManager.IsConnected) { using (ConnectionManager.FlushingFromDtcTransaction) + { + logger.Debug(string.Format("[session-id={0}] Flushing from Dtc Transaction", sessionId)); Flush(); + } } logger.Debug("prepared for DTC transaction"); @@ -333,7 +336,6 @@ { logger.Error("DTC transaction prepre phase failed", exception); preparingEnlistment.ForceRollback(exception); - } } } @@ -382,13 +384,21 @@ AfterTransactionBegin(null); ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) { - bool wasSuccessful = e.Transaction.TransactionInformation.Status - == TransactionStatus.Committed; - AfterTransactionCompletion(wasSuccessful, null); - if (shouldCloseSessionOnDtcTransactionCompleted) + bool wasSuccessful = false; + try { - Dispose(true); + wasSuccessful = e.Transaction.TransactionInformation.Status + == TransactionStatus.Committed; } + catch (ObjectDisposedException ode) + { + logger.Warn("Completed transaction was disposed.", ode); + } + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + { + Dispose(true); + } ambientTransation = null; }; ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -226,7 +226,7 @@ if (log.IsDebugEnabled) { - log.Debug("opened session at timestamp: " + timestamp); + log.Debug(string.Format("[session-id={0}]opened session at timestamp:{1}", sessionId, timestamp)); } CheckAndUpdateSessionStatus(); @@ -1655,7 +1655,7 @@ { using (new SessionIdLoggingContext(sessionId)) { - log.Debug("running ISession.Dispose()"); + log.Debug(string.Format("[session-id={0}]running ISession.Dispose()",sessionId)); if (TakingPartInDtcTransaction) { shouldCloseSessionOnDtcTransactionCompleted = true; @@ -1684,6 +1684,8 @@ return; } + log.Debug(string.Format("[session-id={0}]executing real Dispose({1})", sessionId, isDisposing)); + // free managed resources that are being managed by the session if we // know this call came through Dispose() if (isDisposing && !IsClosed) Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -2,6 +2,8 @@ using System.Collections; using System.Threading; using System.Transactions; +using log4net; +using log4net.Repository.Hierarchy; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.DtcFailures @@ -9,9 +11,11 @@ [TestFixture] public class DtcFailuresFixture : TestCase { + private static readonly ILog log = LogManager.GetLogger(typeof(DtcFailuresFixture)); + protected override IList Mappings { - get { return new string[] {"NHSpecificTest.DtcFailures.Mappings.hbm.xml"}; } + get { return new[] {"NHSpecificTest.DtcFailures.Mappings.hbm.xml"}; } } protected override string MappingsAssembly @@ -51,7 +55,7 @@ using (ISession s = sessions.OpenSession()) { new ForceEscalationToDistributedTx(true); //will rollback tx - s.Save(new Person {CreatedAt = DateTime.Today}); + s.Save(new Person { CreatedAt = DateTime.Today }); tx.Complete(); } @@ -67,6 +71,151 @@ } [Test] + [Description("Another action inside the transaction do the rollBack outside nh-session-scope.")] + public void RollbackOutsideNh() + { + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person { CreatedAt = DateTime.Now }; + s.Save(person); + } + new ForceEscalationToDistributedTx(true); //will rollback tx + + txscope.Complete(); + } + + log.DebugFormat("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.DebugFormat("Transaction aborted."); + } + } + + [Test] + [Description("rollback inside nh-session-scope should not commit save and the transaction should be aborted.")] + public void TransactionInsertWithRollBackTask() + { + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person {CreatedAt = DateTime.Now}; + s.Save(person); + new ForceEscalationToDistributedTx(true); //will rollback tx + person.CreatedAt = DateTime.Now; + s.Update(person); + } + txscope.Complete(); + } + log.DebugFormat("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.DebugFormat("Transaction aborted."); + } + } + + [Test, Ignore("Not fixed.")] + [Description(@"Two session in two txscope +(without an explicit NH transaction and without an explicit flush) +and with a rollback in the second dtc and a ForceRollback outside nh-session-scope.")] + public void TransactionInsertLoadWithRollBackTask() + { + object savedId; + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person {CreatedAt = DateTime.Now}; + savedId = s.Save(person); + } + txscope.Complete(); + } + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = s.Get<Person>(savedId); + person.CreatedAt = DateTime.Now; + s.Update(person); + } + new ForceEscalationToDistributedTx(true); + + log.Debug("completing the tx scope"); + txscope.Complete(); + } + log.Debug("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.Debug("Transaction aborted."); + } + finally + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = s.Get<Person>(savedId); + s.Delete(person); + } + txscope.Complete(); + } + } + } + + private int totalCall; + + [Test, Explicit] + public void MultiThreadedTransaction() + { + // Test added for NH-1709 (trying to recreate the issue... without luck) + // If one thread break the test, you can see the result in the console. + ((Logger)log.Logger).Level = log4net.Core.Level.Debug; + var actions = new MultiThreadRunner<object>.ExecuteAction[] + { + delegate(object o) + { + Can_roll_back_transaction(); + totalCall++; + }, + delegate(object o) + { + RollbackOutsideNh(); + totalCall++; + }, + delegate(object o) + { + TransactionInsertWithRollBackTask(); + totalCall++; + }, + //delegate(object o) + // { + // TransactionInsertLoadWithRollBackTask(); + // totalCall++; + // }, + }; + var mtr = new MultiThreadRunner<object>(20, actions) + { + EndTimeout = 5000, TimeoutBetweenThreadStart = 5 + }; + mtr.Run(null); + log.DebugFormat("{0} calls", totalCall); + } + + [Test] public void CanDeleteItemInDtc() { object id; @@ -95,6 +244,26 @@ } } + [Test] + [Description("Open/Close a session inside a TransactionScope fails.")] + public void NH1744() + { + using (var tx = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + s.Flush(); + } + + using (ISession s = sessions.OpenSession()) + { + s.Flush(); + } + + //and I always leave the transaction disposed without calling tx.Complete(), I let the database server to rollback all actions in this test. + } + } + public class ForceEscalationToDistributedTx : IEnlistmentNotification { private readonly bool shouldRollBack; @@ -114,6 +283,7 @@ Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); if (shouldRollBack) { + log.Debug(">>>>Force Rollback<<<<<"); preparingEnlistment.ForceRollback(); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-14 11:35:40
|
Revision: 4299 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4299&view=rev Author: steverstrong Date: 2009-05-14 11:35:34 +0000 (Thu, 14 May 2009) Log Message: ----------- Another minor clean up within AST parser, and a fix for NH-1773 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -847,15 +847,11 @@ if ( fromElements.Count == 1 ) { FromElement fromElement = (FromElement) fromElements[0]; - try - { - log.Info( "attempting to resolve property [" + identText + "] as a non-qualified ref" ); - return fromElement.GetPropertyMapping(identText).ToType(identText) != null; - } - catch( QueryException ) - { - // Should mean that no such property was found - } + + log.Info( "attempting to resolve property [" + identText + "] as a non-qualified ref" ); + + IType type; + return fromElement.GetPropertyMapping(identText).TryToType(identText, out type); } return false; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -136,6 +136,16 @@ //sqlResultTypeList.addAll( constructorArgumentTypeList ); queryReturnTypeList.AddRange(constructorArgumentTypeList ); _scalarSelect = true; + + for (int j = 1; j < _constructorNode.ChildCount; j++) + { + ISelectExpression se = _constructorNode.GetChild(j) as ISelectExpression; + + if (se != null && IsReturnableEntity(se)) + { + _fromElementsForLoad.Add(se.FromElement); + } + } } else { @@ -227,7 +237,7 @@ // generate id select fragment and then property select fragment for // each expression, just like generateSelectFragments(). - RenderNonScalarSelects( CollectSelectExpressions(), fromClause ); + RenderNonScalarSelects( CollectSelectExpressions(true), fromClause ); } if ( _scalarSelect || Walker.IsShallowQuery ) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -20,8 +20,16 @@ /// <summary> /// Returns an array of SelectExpressions gathered from the children of the given parent AST node. /// </summary> - public ISelectExpression[] CollectSelectExpressions() + public ISelectExpression[] CollectSelectExpressions() { + return CollectSelectExpressions(false); + } + + /// <summary> + /// Returns an array of SelectExpressions gathered from the children of the given parent AST node. + /// </summary> + public ISelectExpression[] CollectSelectExpressions(bool recurse) + { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). IASTNode firstChild = GetFirstSelectExpression(); @@ -30,14 +38,47 @@ for (IASTNode n = firstChild; n != null; n = n.NextSibling) { - var se = n as ISelectExpression; - if (se != null) + if (recurse) { - list.Add(se); + var ctor = n as ConstructorNode; + + if (ctor != null) + { + for (IASTNode cn = ctor.GetChild(1); cn != null; cn = cn.NextSibling) + { + var se = cn as ISelectExpression; + if (se != null) + { + list.Add(se); + } + } + } + else + { + var se = n as ISelectExpression; + if (se != null) + { + list.Add(se); + } + else + { + throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + + new ASTPrinter().ShowAsString(n, "")); + } + } } else { - throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + new ASTPrinter().ShowAsString(n, "")); + var se = n as ISelectExpression; + if (se != null) + { + list.Add(se); + } + else + { + throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + + new ASTPrinter().ShowAsString(n, "")); + } } } Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1304,6 +1304,19 @@ return elementPropertyMapping.ToType(propertyName); } + public bool TryToType(string propertyName, out IType type) + { + if ("index".Equals(propertyName)) + { + type = indexType; + return true; + } + else + { + return elementPropertyMapping.TryToType(propertyName, out type); + } + } + public string GetManyToManyFilterFragment(string alias, IDictionary<string, IFilter> enabledFilters) { StringBuilder buffer = new StringBuilder(); Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1,3 +1,4 @@ +using System; using NHibernate.Persister.Entity; using NHibernate.Type; @@ -42,6 +43,20 @@ } } + public bool TryToType(string propertyName, out IType type) + { + try + { + type = ToType(propertyName); + return true; + } + catch (Exception) + { + type = null; + return false; + } + } + public string[] ToColumns(string alias, string propertyName) { string[] cols; Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1,3 +1,4 @@ +using System; using NHibernate.Persister.Entity; using NHibernate.Type; using NHibernate.Util; @@ -32,6 +33,20 @@ } } + public bool TryToType(string propertyName, out IType outType) + { + try + { + outType = ToType(propertyName); + return true; + } + catch (Exception) + { + outType = null; + return false; + } + } + public string[] ToColumns(string alias, string propertyName) { if (propertyName == null || "id".Equals(propertyName)) Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1720,6 +1720,11 @@ return propertyMapping.ToType(propertyName); } + public bool TryToType(string propertyName, out IType type) + { + return propertyMapping.TryToType(propertyName, out type); + } + public string[] GetPropertyColumnNames(string propertyName) { return propertyMapping.GetColumnNames(propertyName); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -43,6 +43,11 @@ } } + public bool TryToType(string propertyName, out IType type) + { + return typesByPropertyPath.TryGetValue(propertyName, out type); + } + public virtual string[] ToColumns(string alias, string propertyName) { //TODO: *two* hashmap lookups here is one too many... Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -22,6 +22,14 @@ IType ToType(string propertyName); /// <summary> + /// Given a component path expression, get the type of the property. + /// </summary> + /// <param name="propertyName"></param> + /// <param name="type"></param> + /// <returns>true if a type was found, false if not</returns> + bool TryToType(string propertyName, out IType type); + + /// <summary> /// Given a query alias and a property path, return the qualified column name /// </summary> /// <param name="alias"></param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 17:40:20
|
Revision: 4304 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4304&view=rev Author: fabiomaulo Date: 2009-05-14 17:40:11 +0000 (Thu, 14 May 2009) Log Message: ----------- Fix NH-1776 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-14 17:40:11 UTC (rev 4304) @@ -77,7 +77,7 @@ { if (entry.SqlLocations[index] >= existingParameterLocation) { - entry.SqlLocations[index]++; + entry.IncrementLocation(index); } } } @@ -138,30 +138,36 @@ } } + [Serializable] public class ParameterInfo { - private readonly int[] _sqlLocations; - private readonly IType _expectedType; + private readonly int[] originalLocation; + private readonly int[] sqlLocations; public ParameterInfo(int[] sqlPositions, IType expectedType) { - _sqlLocations = sqlPositions; - _expectedType = expectedType; + originalLocation = (int[])sqlPositions.Clone(); + sqlLocations = sqlPositions; + ExpectedType = expectedType; } - public ParameterInfo(int sqlPosition, IType expectedType) { - _sqlLocations = new int[] { sqlPosition }; - _expectedType = expectedType; + public ParameterInfo(int sqlPosition, IType expectedType) + { + originalLocation = new[] { sqlPosition }; + sqlLocations = new[] { sqlPosition }; + ExpectedType = expectedType; } public int[] SqlLocations { - get { return _sqlLocations; } + get { return sqlLocations; } } - public IType ExpectedType + public IType ExpectedType { get; private set; } + + public void IncrementLocation(int index) { - get { return _expectedType; } + sqlLocations[index] = originalLocation[index] + 1; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 17:40:11 UTC (rev 4304) @@ -3,34 +3,42 @@ namespace NHibernate.Test.NHSpecificTest.NH1776 { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class FilterQueryTwiceFixture : BugTestCase { + // Note : in this test what is really important is the usage of the same HQL + // because QueryPlan + [Test] [Description("Can Query using Session's filter Twice")] public void Bug() { + var c = new Category { Code = "2600", Deleted = false }; + SaveCategory(c); + + // exec queries, twice, different session + ExecQuery(); + ExecQuery(); + + // cleanup using filter using (ISession s = OpenSession()) { using (ITransaction tx = s.BeginTransaction()) { - var c = new Category {Code = "2600", Deleted = false}; - s.SaveOrUpdate(c); + s.EnableFilter("state").SetParameter("deleted", false); + s.Delete("from Category"); tx.Commit(); } } + } - // exec queries, twice, different session - ExecQuery(); - ExecQuery(); - - // cleanup + private void SaveCategory(Category c) + { using (ISession s = OpenSession()) { using (ITransaction tx = s.BeginTransaction()) { - s.EnableFilter("state").SetParameter("deleted", false); - s.Delete("from Category"); + s.Save(c); tx.Commit(); } } @@ -48,5 +56,93 @@ Assert.That(result.Count > 0); } } + + [Test] + [Description("Executing same query with and without filter and with different filter parameter value.")] + public void FilterOnOffOn() + { + var c = new Category { Code = "2600", Deleted = true }; + SaveCategory(c); + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", false); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", true); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + + Cleanup(); + } + + private void Cleanup() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from Category").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + [Description("Executing same query with different filters combinations.")] + public void MultiFilterOnOffOn() + { + var c = new Category { Code = "2600", Deleted = true }; + SaveCategory(c); + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", false); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", true); + s.EnableFilter("CodeLike").SetParameter("codepattern", "2%"); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "NotExists").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("CodeLike").SetParameter("codepattern", "2%"); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + Cleanup(); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 17:40:11 UTC (rev 4304) @@ -10,10 +10,15 @@ <property name="Code"/> <property name="Deleted"/> <filter name="state" condition=":deleted = Deleted"/> + <filter name="CodeLike" condition="Code like :codepattern"/> </class> <filter-def name="state" condition=":deleted = Deleted"> <filter-param name="deleted" type="Boolean"/> </filter-def> + + <filter-def name="CodeLike"> + <filter-param name="codepattern" type="string"/> + </filter-def> </hibernate-mapping> \ 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-14 21:10:43
|
Revision: 4305 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4305&view=rev Author: fabiomaulo Date: 2009-05-14 21:10:28 +0000 (Thu, 14 May 2009) Log Message: ----------- Applied patch NH-1777 (by Roger) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs trunk/nhibernate/src/NHibernate/Criterion/Example.cs trunk/nhibernate/src/NHibernate/Engine/Cascade.cs trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs Modified: trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -34,9 +34,11 @@ public override bool Equals(object other) { - if (!(other is FilterKey)) + var that = other as FilterKey; + if (that == null) + { return false; - FilterKey that = (FilterKey) other; + } if (!that.filterName.Equals(filterName)) return false; if (!CollectionHelper.DictionaryEquals<string, TypedValue>(that.filterParameters, filterParameters)) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -665,9 +665,9 @@ value.SetTypeUsingReflection(className, propertyName, PropertyAccess(subnode)); // This is done here 'cos we might only know the type here (ugly!) - if (value is ToOne) + var toOne = value as ToOne; + if (toOne != null) { - ToOne toOne = (ToOne) value; string propertyRef = toOne.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -236,25 +236,25 @@ model.SqlType = null; } - private Mapping.Property CreateProperty(ToOne value, string propertyName, System.Type parentClass, + private Property CreateProperty(ToOne value, string propertyName, System.Type parentClass, HbmKeyManyToOne keyManyToOneSchema) { if (parentClass != null && value.IsSimpleValue) - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, keyManyToOneSchema.access ?? mappings.DefaultAccess); + value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + keyManyToOneSchema.access ?? mappings.DefaultAccess); string propertyRef = value.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(value.ReferencedEntityName, propertyRef); value.CreateForeignKey(); - Mapping.Property prop = new Mapping.Property(); - prop.Value = value; + var prop = new Property {Value = value}; BindProperty(keyManyToOneSchema, prop); return prop; } - private void BindProperty(HbmKeyManyToOne keyManyToOneSchema, Mapping.Property property) + private void BindProperty(HbmKeyManyToOne keyManyToOneSchema, Property property) { property.Name = keyManyToOneSchema.name; @@ -343,30 +343,30 @@ model.SqlType = null; } - private Mapping.Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass, + private Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass, HbmKeyProperty keyPropertySchema) { if (parentClass != null && value.IsSimpleValue) - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, keyPropertySchema.access ?? mappings.DefaultAccess); + value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + keyPropertySchema.access ?? mappings.DefaultAccess); // This is done here 'cos we might only know the type here (ugly!) - if (value is ToOne) + var toOne = value as ToOne; + if (toOne != null) { - ToOne toOne = (ToOne) value; string propertyRef = toOne.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef); } value.CreateForeignKey(); - Mapping.Property prop = new Mapping.Property(); - prop.Value = value; + var prop = new Property {Value = value}; BindProperty(keyPropertySchema, prop); return prop; } - private void BindProperty(HbmKeyProperty keyPropertySchema, Mapping.Property property) + private void BindProperty(HbmKeyProperty keyPropertySchema, Property property) { property.Name = keyPropertySchema.name; Modified: trunk/nhibernate/src/NHibernate/Criterion/Example.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -417,9 +417,9 @@ // parameter passed in. if (value != null) { - if (value is string) + var stringValue = value as string; + if (stringValue != null) { - string stringValue = (string) value; if (_isIgnoreCaseEnabled) { stringValue = stringValue.ToLower(); @@ -430,7 +430,8 @@ } value = stringValue; } - list.Add(new TypedValue(type, value, EntityMode.Poco)); // TODO NH Different behavior: In H3.2 EntityMode is nullable + list.Add(new TypedValue(type, value, EntityMode.Poco)); + // TODO NH Different behavior: In H3.2 EntityMode is nullable } } Modified: trunk/nhibernate/src/NHibernate/Engine/Cascade.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Cascade.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/Cascade.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -218,9 +218,11 @@ private void CascadeCollectionElements(object child, CollectionType collectionType, CascadeStyle style, IType elemType, object anything, bool isCascadeDeleteEnabled) { // we can't cascade to non-embedded elements - bool embeddedElements = eventSource.EntityMode != EntityMode.Xml || ((EntityType)collectionType.GetElementType(eventSource.Factory)).IsEmbeddedInXML; + bool embeddedElements = eventSource.EntityMode != EntityMode.Xml + || ((EntityType) collectionType.GetElementType(eventSource.Factory)).IsEmbeddedInXML; - bool reallyDoCascade = style.ReallyDoCascade(action) && embeddedElements && child != CollectionType.UnfetchedCollection; + bool reallyDoCascade = style.ReallyDoCascade(action) && embeddedElements + && child != CollectionType.UnfetchedCollection; if (reallyDoCascade) { @@ -232,8 +234,9 @@ log.Info("done cascade " + action + " for collection: " + collectionType.Role); } - bool deleteOrphans = style.HasOrphanDelete && action.DeleteOrphans && - elemType.IsEntityType && child is IPersistentCollection; //a newly instantiated collection can't have orphans + var childAsPersColl = child as IPersistentCollection; + bool deleteOrphans = style.HasOrphanDelete && action.DeleteOrphans && elemType.IsEntityType + && childAsPersColl != null; //a newly instantiated collection can't have orphans if (deleteOrphans) { @@ -244,7 +247,7 @@ // 1. newly instantiated collections // 2. arrays (we can't track orphans for detached arrays) string entityName = collectionType.GetAssociatedEntityName(eventSource.Factory); - DeleteOrphans(entityName, (IPersistentCollection)child); + DeleteOrphans(entityName, childAsPersColl); log.Info("done deleting orphans for collection: " + collectionType.Role); } Modified: trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -1,6 +1,5 @@ using System; using NHibernate.SqlCommand; -using System.Runtime.Serialization; namespace NHibernate.Engine { @@ -39,12 +38,14 @@ public override bool Equals(object obj) { - if (obj is ExecuteUpdateResultCheckStyle) + var castedObj = obj as ExecuteUpdateResultCheckStyle; + if (castedObj != null) { - return this.name == ((ExecuteUpdateResultCheckStyle) obj).name; + return name == castedObj.name; } return false; } + public override int GetHashCode() { return name.GetHashCode(); Modified: trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -572,14 +572,13 @@ //{ // value = wrapper.Element; //} - - if (value is INHibernateProxy) + var proxy = value as INHibernateProxy; + if (proxy != null) { if (log.IsDebugEnabled) { log.Debug("setting proxy identifier: " + id); } - INHibernateProxy proxy = (INHibernateProxy)value; ILazyInitializer li = proxy.HibernateLazyInitializer; li.Identifier = id; ReassociateProxy(li, proxy); @@ -648,18 +647,14 @@ //{ // maybeProxy = wrapper.Element; //} - - if (maybeProxy is INHibernateProxy) + var proxy = maybeProxy as INHibernateProxy; + if (proxy != null) { - INHibernateProxy proxy = (INHibernateProxy)maybeProxy; ILazyInitializer li = proxy.HibernateLazyInitializer; ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object } - else - { - return maybeProxy; - } + return maybeProxy; } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -11,7 +11,7 @@ { } - private static object[] NoParameters = new object[0]; + private static readonly object[] NoParameters = new object[0]; private static object Instantiate(ConstructorInfo constructor) { @@ -45,47 +45,42 @@ object defaultValue = identifierGetter.Get(Instantiate(constructor)); return new IdentifierValue(defaultValue); } - else if (identifierGetter != null && (identifierType is PrimitiveType)) + var idTypeAsPrimitiveType = identifierType as PrimitiveType; + if (identifierGetter != null && idTypeAsPrimitiveType != null) { - object defaultValue = ((PrimitiveType) identifierType).DefaultValue; + object defaultValue = idTypeAsPrimitiveType.DefaultValue; return new IdentifierValue(defaultValue); } - else - { - return IdentifierValue.SaveNull; - } + return IdentifierValue.SaveNull; } - else if ("null" == unsavedValue) + if ("null" == unsavedValue) { return IdentifierValue.SaveNull; } - else if( "undefined" == unsavedValue ) + if ("undefined" == unsavedValue) { return IdentifierValue.Undefined; } - else if ("none" == unsavedValue) + if ("none" == unsavedValue) { return IdentifierValue.SaveNone; } - else if ("any" == unsavedValue) + if ("any" == unsavedValue) { return IdentifierValue.SaveAny; } - else + try { - try - { - return new IdentifierValue(((IIdentifierType) identifierType).StringToObject(unsavedValue)); - } - catch (InvalidCastException cce) - { - throw new MappingException("Bad identifier type: " + identifierType.Name, cce); - } - catch (Exception e) - { - throw new MappingException("Could not parse identifier unsaved-value: " + unsavedValue, e); - } + return new IdentifierValue(((IIdentifierType) identifierType).StringToObject(unsavedValue)); } + catch (InvalidCastException cce) + { + throw new MappingException("Bad identifier type: " + identifierType.Name, cce); + } + catch (Exception e) + { + throw new MappingException("Could not parse identifier unsaved-value: " + unsavedValue, e); + } } public static VersionValue GetUnsavedVersionValue( Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -169,7 +169,8 @@ private object ReturnNarrowedProxy(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options, IPersistenceContext persistenceContext, object proxy) { log.Debug("entity proxy found in session cache"); - ILazyInitializer li = ((INHibernateProxy)proxy).HibernateLazyInitializer; + var castedProxy = (INHibernateProxy) proxy; + ILazyInitializer li = castedProxy.HibernateLazyInitializer; if (li.Unwrap) { return li.GetImplementation(); @@ -189,7 +190,7 @@ // NH Different behavior : NH-1252 return null; } - return persistenceContext.NarrowProxy((INHibernateProxy)proxy, persister, keyToLoad, impl); + return persistenceContext.NarrowProxy(castedProxy, persister, keyToLoad, impl); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -423,9 +423,10 @@ { throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); } - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { - obj = ((INHibernateProxy)obj).HibernateLazyInitializer.GetImplementation(this); + obj = proxy.HibernateLazyInitializer.GetImplementation(this); if (obj == null) { return LockMode.None; @@ -1288,14 +1289,14 @@ using (new SessionIdLoggingContext(sessionId)) { CheckAndUpdateSessionStatus(); - INHibernateProxy proxy = obj as INHibernateProxy; + var proxy = obj as INHibernateProxy; if (proxy != null) { if (!persistenceContext.ContainsProxy(proxy)) { throw new TransientObjectException("proxy was not associated with the session"); } - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; obj = li.GetImplementation(); } @@ -1513,25 +1514,23 @@ // Actually the case for proxies will probably work even with // the session closed, but do the check here anyway, so that // the behavior is uniform. - - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; if (li.Session != this) { throw new TransientObjectException("The proxy was not associated with this session"); } return li.Identifier; } - else + + EntityEntry entry = persistenceContext.GetEntry(obj); + if (entry == null) { - EntityEntry entry = persistenceContext.GetEntry(obj); - if (entry == null) - { - throw new TransientObjectException("the instance was not associated with this session"); - } - return entry.Id; + throw new TransientObjectException("the instance was not associated with this session"); } + return entry.Id; } } @@ -1940,12 +1939,12 @@ { using (new SessionIdLoggingContext(sessionId)) { - IEntityPersister persister = Factory.GetEntityPersister(entityName); - if (!(persister is IOuterJoinLoadable)) + var persister = Factory.GetEntityPersister(entityName) as IOuterJoinLoadable; + if (persister == null) { throw new MappingException("class persister is not OuterJoinLoadable: " + entityName); } - return (IOuterJoinLoadable)persister; + return persister; } } @@ -1954,13 +1953,13 @@ using (new SessionIdLoggingContext(sessionId)) { CheckAndUpdateSessionStatus(); - - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { //do not use proxiesByKey, since not all //proxies that point to this session's //instances are in that collection! - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; if (li.IsUninitialized) { //if it is an uninitialized proxy, pointing Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -149,11 +149,12 @@ private ISqlLoadable GetSQLLoadable(string entityName) { IEntityPersister persister = factory.GetEntityPersister(entityName); - if (!(persister is ISqlLoadable)) + var persisterAsSqlLoadable = persister as ISqlLoadable; + if (persisterAsSqlLoadable == null) { throw new MappingException("class persister is not ISqlLoadable: " + entityName); } - return (ISqlLoadable) persister; + return persisterAsSqlLoadable; } private string GenerateEntitySuffix() Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -565,8 +565,9 @@ PostLoadEvent post; if (session.IsEventSource) { - pre = new PreLoadEvent((IEventSource) session); - post = new PostLoadEvent((IEventSource) session); + var eventSourceSession = (IEventSource) session; + pre = new PreLoadEvent(eventSourceSession); + post = new PostLoadEvent(eventSourceSession); } else { Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -156,23 +156,24 @@ public static string[][] To2DStringArray(ICollection coll) { - string[][] result = new string[ coll.Count ][]; + var result = new string[ coll.Count ][]; int i = 0; foreach (object row in coll) { - if (row is ICollection) + var rowAsCollection = row as ICollection; + if (rowAsCollection != null) { - result[i] = new string[((ICollection)row).Count]; + result[i] = new string[rowAsCollection.Count]; int j = 0; - foreach (object cell in (ICollection)row) + foreach (object cell in rowAsCollection) { - result[i][j++] = cell == null ? null : (string)cell; + result[i][j++] = cell == null ? null : (string) cell; } } else { result[i] = new string[1]; - result[i][0] = row == null ? null : (string)row; + result[i][0] = row == null ? null : (string) row; } i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-15 07:44:45
|
Revision: 4313 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4313&view=rev Author: ayenderahien Date: 2009-05-15 07:44:35 +0000 (Fri, 15 May 2009) Log Message: ----------- SqlClientBatchingBatcher will now log to added statements consistently, regardless if AbstractBatcher is enabled or not. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs trunk/nhibernate/src/NHibernate.Test/LogSpy.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -50,7 +50,7 @@ } else { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) Modified: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -120,7 +120,7 @@ sessions.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); - Assert.That(logs, Text.DoesNotContain("batch").IgnoreCase); + Assert.That(logs, Text.DoesNotContain("batcher").IgnoreCase); Assert.That(logs, Text.Contains("INSERT").IgnoreCase); } } Modified: trunk/nhibernate/src/NHibernate.Test/LogSpy.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -48,7 +48,10 @@ var wholeMessage = new StringBuilder(); foreach (LoggingEvent loggingEvent in Appender.GetEvents()) { - wholeMessage.Append(loggingEvent.RenderedMessage); + wholeMessage + .Append(loggingEvent.LoggerName) + .Append(" ") + .Append(loggingEvent.RenderedMessage); } return wholeMessage.ToString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-15 08:03:02
|
Revision: 4315 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4315&view=rev Author: steverstrong Date: 2009-05-15 08:02:51 +0000 (Fri, 15 May 2009) Log Message: ----------- Fix and test for NH-1775 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTErrorNode.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1775/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1775/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1775/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1775/Member.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-05-15 07:46:31 UTC (rev 4314) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-05-15 08:02:51 UTC (rev 4315) @@ -1,4587 +1,4719 @@ -// $ANTLR 3.1.2 C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g 2009-05-05 16:12:32 - -// 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; -using Antlr.Runtime; -using IList = System.Collections.IList; -using ArrayList = System.Collections.ArrayList; -using Stack = Antlr.Runtime.Collections.StackList; - -using IDictionary = System.Collections.IDictionary; -using Hashtable = System.Collections.Hashtable; - -public partial class HqlLexer : Lexer { - public const int LT = 104; - public const int EXPONENT = 123; - public const int STAR = 111; - public const int FLOAT_SUFFIX = 124; - public const int LITERAL_by = 54; - 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 BOTH = 62; - 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 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 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 ORDER = 41; - public const int MAX = 35; - public const int UPDATE = 51; - 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 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 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 ROW_STAR = 86; - public const int NOT_LIKE = 82; - 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 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 HqlLexer() - { - InitializeCyclicDFAs(); - } - public HqlLexer(ICharStream input) - : this(input, null) { - } - public HqlLexer(ICharStream input, RecognizerSharedState state) - : base(input, state) { - InitializeCyclicDFAs(); - - } - - override public string GrammarFileName - { - get { return "C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g";} - } - - // $ANTLR start "ALL" - public void mALL() // throws RecognitionException [2] - { - try - { - int _type = ALL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:9:5: ( 'all' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:9:7: 'all' - { - Match("all"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ALL" - - // $ANTLR start "ANY" - public void mANY() // throws RecognitionException [2] - { - try - { - int _type = ANY; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:10:5: ( 'any' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:10:7: 'any' - { - Match("any"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ANY" - - // $ANTLR start "AND" - public void mAND() // throws RecognitionException [2] - { - try - { - int _type = AND; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:11:5: ( 'and' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:11:7: 'and' - { - Match("and"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AND" - - // $ANTLR start "AS" - public void mAS() // throws RecognitionException [2] - { - try - { - int _type = AS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:12:4: ( 'as' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:12:6: 'as' - { - Match("as"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AS" - - // $ANTLR start "ASCENDING" - public void mASCENDING() // throws RecognitionException [2] - { - try - { - int _type = ASCENDING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:13:11: ( 'asc' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:13:13: 'asc' - { - Match("asc"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ASCENDING" - - // $ANTLR start "AVG" - public void mAVG() // throws RecognitionException [2] - { - try - { - int _type = AVG; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:14:5: ( 'avg' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:14:7: 'avg' - { - Match("avg"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AVG" - - // $ANTLR start "BETWEEN" - public void mBETWEEN() // throws RecognitionException [2] - { - try - { - int _type = BETWEEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:15:9: ( 'between' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:15:11: 'between' - { - Match("between"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BETWEEN" - - // $ANTLR start "CLASS" - public void mCLASS() // throws RecognitionException [2] - { - try - { - int _type = CLASS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:16:7: ( 'class' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:16:9: 'class' - { - Match("class"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLASS" - - // $ANTLR start "COUNT" - public void mCOUNT() // throws RecognitionException [2] - { - try - { - int _type = COUNT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:17:7: ( 'count' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:17:9: 'count' - { - Match("count"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "COUNT" - - // $ANTLR start "DELETE" - public void mDELETE() // throws RecognitionException [2] - { - try - { - int _type = DELETE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:18:8: ( 'delete' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:18:10: 'delete' - { - Match("delete"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DELETE" - - // $ANTLR start "DESCENDING" - public void mDESCENDING() // throws RecognitionException [2] - { - try - { - int _type = DESCENDING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:19:12: ( 'desc' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:19:14: 'desc' - { - Match("desc"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DESCENDING" - - // $ANTLR start "DISTINCT" - public void mDISTINCT() // throws RecognitionException [2] - { - try - { - int _type = DISTINCT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:20:10: ( 'distinct' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:20:12: 'distinct' - { - Match("distinct"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DISTINCT" - - // $ANTLR start "ELEMENTS" - public void mELEMENTS() // throws RecognitionException [2] - { - try - { - int _type = ELEMENTS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:21:10: ( 'elements' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:21:12: 'elements' - { - Match("elements"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ELEMENTS" - - // $ANTLR start "ESCAPE" - public void mESCAPE() // throws RecognitionException [2] - { - try - { - int _type = ESCAPE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:22:8: ( 'escape' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:22:10: 'escape' - { - Match("escape"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ESCAPE" - - // $ANTLR start "EXISTS" - public void mEXISTS() // throws RecognitionException [2] - { - try - { - int _type = EXISTS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:23:8: ( 'exists' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:23:10: 'exists' - { - Match("exists"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EXISTS" - - // $ANTLR start "FALSE" - public void mFALSE() // throws RecognitionException [2] - { - try - { - int _type = FALSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:24:7: ( 'false' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:24:9: 'false' - { - Match("false"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FALSE" - - // $ANTLR start "FETCH" - public void mFETCH() // throws RecognitionException [2] - { - try - { - int _type = FETCH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:25:7: ( 'fetch' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:25:9: 'fetch' - { - Match("fetch"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FETCH" - - // $ANTLR start "FROM" - public void mFROM() // throws RecognitionException [2] - { - try - { - int _type = FROM; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:26:6: ( 'from' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:26:8: 'from' - { - Match("from"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FROM" - - // $ANTLR start "FULL" - public void mFULL() // throws RecognitionException [2] - { - try - { - int _type = FULL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:27:6: ( 'full' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:27:8: 'full' - { - Match("full"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FULL" - - // $ANTLR start "GROUP" - public void mGROUP() // throws RecognitionException [2] - { - try - { - int _type = GROUP; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:28:7: ( 'group' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:28:9: 'group' - { - Match("group"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GROUP" - - // $ANTLR start "HAVING" - public void mHAVING() // throws RecognitionException [2] - { - try - { - int _type = HAVING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:29:8: ( 'having' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:29:10: 'having' - { - Match("having"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "HAVING" - - // $ANTLR start "IN" - public void mIN() // throws RecognitionException [2] - { - try - { - int _type = IN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:30:4: ( 'in' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:30:6: 'in' - { - Match("in"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "IN" - - // $ANTLR start "INDICES" - public void mINDICES() // throws RecognitionException [2] - { - try - { - int _type = INDICES; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:31:9: ( 'indices' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:31:11: 'indices' - { - Match("indices"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INDICES" - - // $ANTLR start "INNER" - public void mINNER() // throws RecognitionException [2] - { - try - { - int _type = INNER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:32:7: ( 'inner' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:32:9: 'inner' - { - Match("inner"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INNER" - - // $ANTLR start "INSERT" - public void mINSERT() // throws RecognitionException [2] - { - try - { - int _type = INSERT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:33:8: ( 'insert' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:33:10: 'insert' - { - Match("insert"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INSERT" - - // $ANTLR start "INTO" - public void mINTO() // throws RecognitionException [2] - { - try - { - int _type = INTO; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:34:6: ( 'into' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:34:8: 'into' - { - Match("into"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INTO" - - // $ANTLR start "IS" - public void mIS() // throws RecognitionException [2] - { - try - { - int _type = IS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:35:4: ( 'is' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:35:6: 'is' - { - Match("is"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "IS" - - // $ANTLR start "JOIN" - public void mJOIN() // throws RecognitionException [2] - { - try - { - int _type = JOIN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:36:6: ( 'join' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:36:8: 'join' - { - Match("join"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "JOIN" - - // $ANTLR start "LEFT" - public void mLEFT() // throws RecognitionException [2] - { - try - { - int _type = LEFT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:37:6: ( 'left' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:37:8: 'left' - { - Match("left"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LEFT" - - // $ANTLR start "LIKE" - public void mLIKE() // throws RecognitionException [2] - { - try - { - int _type = LIKE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:38:6: ( 'like' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:38:8: 'like' - { - Match("like"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LIKE" - - // $ANTLR start "MAX" - public void mMAX() // throws RecognitionException [2] - { - try - { - int _type = MAX; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:39:5: ( 'max' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:39:7: 'max' - { - Match("max"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MAX" - - // $ANTLR start "MIN" - public void mMIN() // throws RecognitionException [2] - { - try - { - int _type = MIN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:40:5: ( 'min' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:40:7: 'min' - { - Match("min"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MIN" - - // $ANTLR start "NEW" - public void mNEW() // throws RecognitionException [2] - { - try - { - int _type = NEW; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:41:5: ( 'new' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:41:7: 'new' - { - Match("new"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NEW" - - // $ANTLR start "NOT" - public void mNOT() // throws RecognitionException [2] - { - try - { - int _type = NOT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:42:5: ( 'not' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:42:7: 'not' - { - Match("not"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NOT" - - // $ANTLR start "NULL" - public void mNULL() // throws RecognitionException [2] - { - try - { - int _type = NULL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:43:6: ( 'null' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:43:8: 'null' - { - Match("null"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NULL" - - // $ANTLR start "OR" - public void mOR() // throws RecognitionException [2] - { - try - { - int _type = OR; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:44:4: ( 'or' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:44:6: 'or' - { - Match("or"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OR" - - // $ANTLR start "ORDER" - public void mORDER() // throws RecognitionException [2] - { - try - { - int _type = ORDER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:45:7: ( 'order' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:45:9: 'order' - { - Match("order"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ORDER" - - // $ANTLR start "OUTER" - public void mOUTER() // throws RecognitionException [2] - { - try - { - int _type = OUTER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:46:7: ( 'outer' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:46:9: 'outer' - { - Match("outer"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OUTER" - - // $ANTLR start "PROPERTIES" - public void mPROPERTIES() // throws RecognitionException [2] - { - try - { - int _type = PROPERTIES; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:47:12: ( 'properties' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:47:14: 'properties' - { - Match("properties"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "PROPERTIES" - - // $ANTLR start "RIGHT" - public void mRIGHT() // throws RecognitionException [2] - { - try - { - int _type = RIGHT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:48:7: ( 'right' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:48:9: 'right' - { - Match("right"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "RIGHT" - - // $ANTLR start "SELECT" - public void mSELECT() // throws RecognitionException [2] - { - try - { - int _type = SELECT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:49:8: ( 'select' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:49:10: 'select' - { - Match("select"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SELECT" - - // $ANTLR start "SET" - public void mSET() // throws RecognitionException [2] - { - try - { - int _type = SET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:50:5: ( 'set' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:50:7: 'set' - { - Match("set"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SET" - - // $ANTLR start "SOME" - public void mSOME() // throws RecognitionException [2] - { - try - { - int _type = SOME; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:51:6: ( 'some' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:51:8: 'some' - { - Match("some"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SOME" - - // $ANTLR start "SUM" - public void mSUM() // throws RecognitionException [2] - { - try - { - int _type = SUM; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:52:5: ( 'sum' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:52:7: 'sum' - { - Match("sum"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SUM" - - // $ANTLR start "TRUE" - public void mTRUE() // throws RecognitionException [2] - { - try - { - int _type = TRUE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:53:6: ( 'true' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:53:8: 'true' - { - Match("true"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "TRUE" - - // $ANTLR start "UNION" - public void mUNION() // throws RecognitionException [2] - { - try - { - int _type = UNION; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:54:7: ( 'union' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:54:9: 'union' - { - Match("union"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "UNION" - - // $ANTLR start "UPDATE" - public void mUPDATE() // throws RecognitionException [2] - { - try - { - int _type = UPDATE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:55:8: ( 'update' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:55:10: 'update' - { - Match("update"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "UPDATE" - - // $ANTLR start "VERSIONED" - public void mVERSIONED() // throws RecognitionException [2] - { - try - { - int _type = VERSIONED; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:56:11: ( 'versioned' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:56:13: 'versioned' - { - Match("versioned"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "VERSIONED" - - // $ANTLR start "WHERE" - public void mWHERE() // throws RecognitionException [2] - { - try - { - int _type = WHERE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:57:7: ( 'where' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:57:9: 'where' - { - Match("where"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WHERE" - - // $ANTLR start "LITERAL_by" - public void mLITERAL_by() // throws RecognitionException [2] - { - try - { - int _type = LITERAL_by; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:58:12: ( 'by' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:58:14: 'by' - { - Match("by"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LITERAL_by" - - // $ANTLR start "CASE" - public void mCASE() // throws RecognitionException [2] - { - try - { - int _type = CASE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:59:6: ( 'case' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:59:8: 'case' - { - Match("case"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CASE" - - // $ANTLR start "END" - public void mEND() // throws RecognitionException [2] - { - try - { - int _type = END; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:60:5: ( 'end' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:60:7: 'end' - { - Match("end"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "END" - - // $ANTLR start "ELSE" - public void mELSE() // throws RecognitionException [2] - { - try - { - int _type = ELSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:61:6: ( 'else' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:61:8: 'else' - { - Match("else"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ELSE" - - // $ANTLR start "THEN" - public void mTHEN() // throws RecognitionException [2] - { - try - { - int _type = THEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:62:6: ( 'then' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:62:8: 'then' - { - Match("then"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "THEN" - - // $ANTLR start "WHEN" - public void mWHEN() // throws RecognitionException [2] - { - try - { - int _type = WHEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:63:6: ( 'when' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:63:8: 'when' - { - Match("when"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WHEN" - - // $ANTLR start "ON" - public void mON() // throws RecognitionException [2] - { - try - { - int _type = ON; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:64:4: ( 'on' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:64:6: 'on' - { - Match("on"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ON" - - // $ANTLR start "WITH" - public void mWITH() // throws RecognitionException [2] - { - try - { - int _type = WITH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:65:6: ( 'with' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:65:8: 'with' - { - Match("with"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WITH" - - // $ANTLR start "BOTH" - public void mBOTH() // throws RecognitionException [2] - { - try - { - int _type = BOTH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:66:6: ( 'both' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:66:8: 'both' - { - Match("both"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BOTH" - - // $ANTLR start "EMPTY" - public void mEMPTY() // throws RecognitionException [2] - { - try - { - int _type = EMPTY; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:67:7: ( 'empty' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:67:9: 'empty' - { - Match("empty"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EMPTY" - - // $ANTLR start "LEADING" - public void mLEADING() // throws RecognitionException [2] - { - try - { - int _type = LEADING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:68:9: ( 'leading' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:68:11: 'leading' - { - Match("leading"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LEADING" - - // $ANTLR start "MEMBER" - public void mMEMBER() // throws RecognitionException [2] - { - try - { - int _type = MEMBER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:69:8: ( 'member' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:69:10: 'member' - { - Match("member"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MEMBER" - - // $ANTLR start "OBJECT" - public void mOBJECT() // throws RecognitionException [2] - { - try - { - int _type = OBJECT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:70:8: ( 'object' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:70:10: 'object' - { - Match("object"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OBJECT" - - // $ANTLR start "OF" - public void mOF() // throws RecognitionException [2] - { - try - { - int _type = OF; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:71:4: ( 'of' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:71:6: 'of' - { - Match("of"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OF" - - // $ANTLR start "TRAILING" - public void mTRAILING() // throws RecognitionException [2] - { - try - { - int _type = TRAILING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:72:10: ( 'trailing' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:72:12: 'trailing' - { - Match("trailing"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "TRAILING" - - // $ANTLR start "T__126" - public void mT__126() // throws RecognitionException [2] - { - try - { - int _type = T__126; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:73:8: ( 'ascending' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:73:10: 'ascending' - { - Match("ascending"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "T__126" - - // $ANTLR start "T__127" - public void mT__127() // throws RecognitionException [2] - { - try - { - int _type = T__127; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:74:8: ( 'descending' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:74:10: 'descending' - { - Match("descending"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "T__127" - - // $ANTLR start "EQ" - public void mEQ() // throws RecognitionException [2] - { - try - { - int _type = EQ; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:741:3: ( '=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:741:5: '=' - { - Match('='); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EQ" - - // $ANTLR start "LT" - public void mLT() // throws RecognitionException [2] - { - try - { - int _type = LT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:742:3: ( '<' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:742:5: '<' - { - Match('<'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LT" - - // $ANTLR start "GT" - public void mGT() // throws RecognitionException [2] - { - try - { - int _type = GT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:743:3: ( '>' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:743:5: '>' - { - Match('>'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GT" - - // $ANTLR start "SQL_NE" - public void mSQL_NE() // throws RecognitionException [2] - { - try - { - int _type = SQL_NE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:744:7: ( '<>' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:744:9: '<>' - { - Match("<>"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SQL_NE" - - // $ANTLR start "NE" - public void mNE() // throws RecognitionException [2] - { - try - { - int _type = NE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:745:3: ( '!=' | '^=' ) - int alt1 = 2; - int LA1_0 = input.LA(1); - - if ( (LA1_0 == '!') ) - { - alt1 = 1; - } - else if ( (LA1_0 == '^') ) - { - alt1 = 2; - } - else - { - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d1s0 = - new NoViableAltException("", 1, 0, input); - - throw nvae_d1s0; - } - switch (alt1) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:745:5: '!=' - { - Match("!="); if (state.failed) return ; - - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:745:12: '^=' - { - Match("^="); if (state.failed) return ; - - - } - break; - - } - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NE" - - // $ANTLR start "LE" - public void mLE() // throws RecognitionException [2] - { - try - { - int _type = LE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:746:3: ( '<=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:746:5: '<=' - { - Match("<="); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LE" - - // $ANTLR start "GE" - public void mGE() // throws RecognitionException [2] - { - try - { - int _type = GE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:747:3: ( '>=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:747:5: '>=' - { - Match(">="); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GE" - - // $ANTLR start "COMMA" - public void mCOMMA() // throws RecognitionException [2] - { - try - { - int _type = COMMA; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:749:6: ( ',' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:749:8: ',' - { - Match(','); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "COMMA" - - // $ANTLR start "OPEN" - public void mOPEN() // throws RecognitionException [2] - { - try - { - int _type = OPEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:751:5: ( '(' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:751:7: '(' - { - Match('('); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OPEN" - - // $ANTLR start "CLOSE" - public void mCLOSE() // throws RecognitionException [2] - { - try - { - int _type = CLOSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:752:6: ( ')' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:752:8: ')' - { - Match(')'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLOSE" - - // $ANTLR start "OPEN_BRACKET" - public void mOPEN_BRACKET() // throws RecognitionException [2] - { - try - { - int _type = OPEN_BRACKET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:753:13: ( '[' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:753:15: '[' - { - Match('['); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OPEN_BRACKET" - - // $ANTLR start "CLOSE_BRACKET" - public void mCLOSE_BRACKET() // throws RecognitionException [2] - { - try - { - int _type = CLOSE_BRACKET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:754:14: ( ']' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:754:16: ']' - { - Match(']'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLOSE_BRACKET" - - // $ANTLR start "CONCAT" - public void mCONCAT() // throws RecognitionException [2] - { - try - { - int _type = CONCAT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:756:7: ( '||' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:756:9: '||' - { - Match("||"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CONCAT" - - // $ANTLR start "PLUS" - public void mPLUS() // throws RecognitionException [2] - { - try - { - int _type = PLUS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:757:5: ( '+' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:757:7: '+' - { - Match('+'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "PLUS" - - // $ANTLR start "MINUS" - public void mMINUS() // throws RecognitionException [2] - { - try - { - int _type = MINUS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:758:6: ( '-' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:758:8: '-' - { - Match('-'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MINUS" - - // $ANTLR start "STAR" - public void mSTAR() // throws RecognitionException [2] - { - try - { - int _type = STAR; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:759:5: ( '*' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:759:7: '*' - { - Match('*'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - ... [truncated message content] |
From: <aye...@us...> - 2009-05-15 16:38:55
|
Revision: 4316 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4316&view=rev Author: ayenderahien Date: 2009-05-15 16:38:45 +0000 (Fri, 15 May 2009) Log Message: ----------- Will push batched command to SQL log as a single unit, or to the batcher log if the sql log is disabled Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 08:02:51 UTC (rev 4315) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 16:38:45 UTC (rev 4316) @@ -65,8 +65,13 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled) + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + else if (log.IsDebugEnabled) + { log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } Modified: trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-15 08:02:51 UTC (rev 4315) +++ trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-15 16:38:45 UTC (rev 4316) @@ -139,5 +139,14 @@ { return FormatSql ? style : FormatStyle.None; } + + public void LogBatchCommand(string batchCommand) + { + log.Debug(batchCommand); + if(LogToStdout) + { + Console.Out.WriteLine("NHibernate: " + batchCommand); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 08:02:51 UTC (rev 4315) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 16:38:45 UTC (rev 4316) @@ -160,6 +160,24 @@ } [Test] + public void SqlLogShouldGetBatchCommandNotification() + { + using (new LogSpy(typeof(AbstractBatcher))) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + string logs = sl.GetWholeLog(); + Assert.That(logs, Text.Contains("Batch command:").IgnoreCase); + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] [Description(@"Activating the AbstractBatcher's log the log stream: -should contain well formatted SQL log info")] public void AbstractBatcherLogFormattedSql() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-15 21:47:25
|
Revision: 4321 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4321&view=rev Author: fabiomaulo Date: 2009-05-15 21:47:20 +0000 (Fri, 15 May 2009) Log Message: ----------- Improv class <type> recognition on <element> Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagPartialNameFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsPartialName.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-15 20:55:13 UTC (rev 4320) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-15 21:47:20 UTC (rev 4321) @@ -7,6 +7,7 @@ using log4net; using NHibernate.Mapping; +using NHibernate.Type; using NHibernate.Util; using NHibernate.Cfg.MappingSchema; @@ -69,6 +70,24 @@ return TypeNameParser.Parse(className, mappings.DefaultNamespace, mappings.DefaultAssembly).Type; } + protected static bool NeedQualifiedClassName(string className) + { + if(string.IsNullOrEmpty(className)) + { + return false; + } + if(className.IndexOf('.') > 0) + { + return false; + } + if(TypeFactory.Basic(className) != null) + { + return false; + } + + return true; + } + /// <summary> /// Attempts to find a type by its full name. Throws a <see cref="MappingException" /> /// using the provided <paramref name="errorMessage" /> in case of failure. Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-15 20:55:13 UTC (rev 4320) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-15 21:47:20 UTC (rev 4321) @@ -833,7 +833,13 @@ simpleValue.TypeParameters = parameters; if (typeName != null) + { + if(NeedQualifiedClassName(typeName)) + { + typeName = FullQualifiedClassName(typeName, mappings); + } simpleValue.TypeName = typeName; + } } private void BindColumnsOrFormula(XmlNode node, SimpleValue simpleValue, string path, bool isNullable) Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagPartialNameFixture.cs (from rev 4320, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagPartialNameFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagPartialNameFixture.cs 2009-05-15 21:47:20 UTC (rev 4321) @@ -0,0 +1,14 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.ElementsEnums +{ + [TestFixture] + public class IntEnumsBagPartialNameFixture : AbstractIntEnumsBagFixture + { + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.ElementsEnums.SimpleWithEnumsPartialName.hbm.xml" }; } + } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsPartialName.hbm.xml (from rev 4318, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsPartialName.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsPartialName.hbm.xml 2009-05-15 21:47:20 UTC (rev 4321) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.ElementsEnums"> + + <class name="SimpleWithEnums"> + <id type="int"> + <generator class="native"/> + </id> + + <property name="Something"/> + <bag name="Things"> + <key column="bid"/> + <element type="Something" column="enumvalue"/> + </bag> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 20:55:13 UTC (rev 4320) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 21:47:20 UTC (rev 4321) @@ -330,6 +330,7 @@ <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" /> + <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> <Compile Include="NHSpecificTest\NH1264\Fixture.cs" /> @@ -1795,6 +1796,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnumsPartialName.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1343\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1264\Passenger.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1264\Reservation.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-15 22:37:23
|
Revision: 4322 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4322&view=rev Author: fabiomaulo Date: 2009-05-15 22:37:17 +0000 (Fri, 15 May 2009) Log Message: ----------- Final improvement of type name recognition on <element> Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagNoNameFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsNoName.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-15 21:47:20 UTC (rev 4321) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-15 22:37:17 UTC (rev 4322) @@ -596,8 +596,22 @@ } else if ("element".Equals(name)) { - SimpleValue elt = new SimpleValue(model.CollectionTable); + var elt = new SimpleValue(model.CollectionTable); model.Element = elt; + if(model.IsGeneric) + { + switch (model.GenericArguments.Length) + { + case 1: + // a collection with a generic type parameter + elt.TypeName = model.GenericArguments[0].AssemblyQualifiedName; + break; + case 2: + // a map (IDictionary) with 2 parameters + elt.TypeName = model.GenericArguments[1].AssemblyQualifiedName; + break; + } + } BindSimpleValue(subnode, elt, true, Mapping.Collection.DefaultElementColumnName); } else if ("many-to-many".Equals(name)) Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagNoNameFixture.cs (from rev 4321, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagPartialNameFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagNoNameFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagNoNameFixture.cs 2009-05-15 22:37:17 UTC (rev 4322) @@ -0,0 +1,14 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.ElementsEnums +{ + [TestFixture] + public class IntEnumsBagNoNameFixture : AbstractIntEnumsBagFixture + { + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.ElementsEnums.SimpleWithEnumsNoName.hbm.xml" }; } + } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsNoName.hbm.xml (from rev 4321, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsPartialName.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsNoName.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnumsNoName.hbm.xml 2009-05-15 22:37:17 UTC (rev 4322) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.ElementsEnums"> + + <class name="SimpleWithEnums"> + <id type="int"> + <generator class="native"/> + </id> + + <property name="Something"/> + <bag name="Things"> + <key column="bid"/> + <element column="enumvalue"/> + </bag> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 21:47:20 UTC (rev 4321) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 22:37:17 UTC (rev 4322) @@ -330,6 +330,7 @@ <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" /> + <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagNoNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> @@ -1796,6 +1797,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnumsNoName.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnumsPartialName.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1343\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1264\Passenger.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |