From: <fab...@us...> - 2009-04-22 05:13:09
|
Revision: 4194 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4194&view=rev Author: fabiomaulo Date: 2009-04-22 05:13:07 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Fix NH-1725 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Classic/SelectParser.cs trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs trunk/nhibernate/src/NHibernate.Test/HQL/MaterialResource.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/SelectParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/SelectParser.cs 2009-04-21 19:06:39 UTC (rev 4193) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/SelectParser.cs 2009-04-22 05:13:07 UTC (rev 4194) @@ -150,7 +150,8 @@ else if (funcStack.HasFunctions) { bool constantToken = false; - if (!readyForAliasOrExpression && parenCount != funcStack.NestedFunctionCount) + var expectedParen = parenCount + ((insideNew) ? -1 : 0); + if (!readyForAliasOrExpression && expectedParen != funcStack.NestedFunctionCount) { throw new QueryException("'(' expected after HQL function in SELECT"); } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-04-21 19:06:39 UTC (rev 4193) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-04-22 05:13:07 UTC (rev 4194) @@ -900,6 +900,19 @@ } } + [Test] + public void NH1725() + { + // Only to test the parser + using (ISession s = OpenSession()) + { + var hql = "select new ForNh1725(mr.Description, iif(mr.State= 0,1,0)) from MaterialResource mr"; + s.CreateQuery(hql).List(); + hql = "select new ForNh1725(mr.Description, cast(iif(mr.State= 0,1,0) as int)) from MaterialResource mr"; + s.CreateQuery(hql).List(); + } + } + [Test, Ignore("Not supported yet!")] public void ParameterLikeArgument() { @@ -934,4 +947,15 @@ } } } + public class ForNh1725 + { + public string Description { get; set; } + public int Value { get; set; } + + public ForNh1725(string description, int value) + { + Description = description; + Value = value; + } + } } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/MaterialResource.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/MaterialResource.hbm.xml 2009-04-21 19:06:39 UTC (rev 4193) +++ trunk/nhibernate/src/NHibernate.Test/HQL/MaterialResource.hbm.xml 2009-04-22 05:13:07 UTC (rev 4194) @@ -4,7 +4,7 @@ namespace="NHibernate.Test.Hql" default-access="field.camelcase-underscore" default-lazy="true"> - + <import class="NHibernate.Test.Hql.ForNh1725, NHibernate.Test" rename="ForNh1725"/> <class name="MaterialResource"> <id name ="Id"> <generator class="native" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-22 17:10:45
|
Revision: 4195 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4195&view=rev Author: fabiomaulo Date: 2009-04-22 17:10:35 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Preparing integration with new parser Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-22 05:13:07 UTC (rev 4194) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-22 17:10:35 UTC (rev 4195) @@ -1171,6 +1171,7 @@ <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" /> </ItemGroup> <ItemGroup> + <Folder Include="Hql\Ast\ANTLR\" /> <Folder Include="Loader\Hql\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-22 17:17:08
|
Revision: 4196 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4196&view=rev Author: fabiomaulo Date: 2009-04-22 17:16:55 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Preparing integration with new parser Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/ Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-22 17:10:35 UTC (rev 4195) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-22 17:16:55 UTC (rev 4196) @@ -1171,7 +1171,11 @@ <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" /> </ItemGroup> <ItemGroup> - <Folder Include="Hql\Ast\ANTLR\" /> + <Folder Include="Hql\Ast\ANTLR\Generated\" /> + <Folder Include="Hql\Ast\ANTLR\Loader\" /> + <Folder Include="Hql\Ast\ANTLR\Parameters\" /> + <Folder Include="Hql\Ast\ANTLR\Tree\" /> + <Folder Include="Hql\Ast\ANTLR\Util\" /> <Folder Include="Loader\Hql\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-22 17:10:35 UTC (rev 4195) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-22 17:16:55 UTC (rev 4196) @@ -1862,6 +1862,7 @@ <EmbeddedResource Include="DynamicEntity\Tuplizer\Customer.hbm.xml" /> </ItemGroup> <ItemGroup> + <Folder Include="HQL\Ast\" /> <Folder Include="Properties\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-22 19:46:04
|
Revision: 4199 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4199&view=rev Author: fabiomaulo Date: 2009-04-22 19:45:48 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Removed TODO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate/SqlCommand/InformixJoinFragment.cs trunk/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-04-22 19:29:26 UTC (rev 4198) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-04-22 19:45:48 UTC (rev 4199) @@ -37,8 +37,7 @@ return; } - // TODO if (!fromElement.UseWhereFragment && !joinFragment.HasThetaJoins) - if (!fromElement.UseWhereFragment) + if (!fromElement.UseWhereFragment && !joinFragment.HasThetaJoins) { return; } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/InformixJoinFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/InformixJoinFragment.cs 2009-04-22 19:29:26 UTC (rev 4198) +++ trunk/nhibernate/src/NHibernate/SqlCommand/InformixJoinFragment.cs 2009-04-22 19:45:48 UTC (rev 4199) @@ -33,7 +33,7 @@ for (int j = 0; j < fkColumns.Length; j++) { - //HasThetaJoins = true; + HasThetaJoins = true; afterWhere.Add(" and " + fkColumns[j]); afterWhere.Add("=" + alias + StringHelper.Dot + pkColumns[j]); } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs 2009-04-22 19:29:26 UTC (rev 4198) +++ trunk/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs 2009-04-22 19:45:48 UTC (rev 4199) @@ -19,7 +19,7 @@ for (int j = 0; j < fkColumns.Length; j++) { - //HasThetaJoins = true; + HasThetaJoins = true; afterWhere.Add(" and " + fkColumns[j]); if (joinType == JoinType.RightOuterJoin || joinType == JoinType.FullJoin) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-22 22:12:52
|
Revision: 4200 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4200&view=rev Author: fabiomaulo Date: 2009-04-22 22:12:41 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Fix NH-1754 and adjust of test to check exactly what we need (some RDBMS may store values in different way; for example 1.3f return 1.29999995... in MsSQL) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2009-04-22 19:45:48 UTC (rev 4199) +++ trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2009-04-22 22:12:41 UTC (rev 4200) @@ -1,5 +1,7 @@ using System; using System.Collections; +using System.Data; +using System.Xml; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -13,15 +15,25 @@ [Serializable] public class CastFunction : ISQLFunction, IFunctionGrammar { + private LazyType returnType; #region ISQLFunction Members public IType ReturnType(IType columnType, IMapping mapping) { //note there is a weird implementation in the client side - //TODO: cast that use only costant are not supported in SELECT. Ex: cast(5 as string) - return columnType; + //TODO: cast that use only costant are not supported in SELECT. Ex: cast(5 as string) + return SetLazyType(columnType); } + private LazyType SetLazyType(IType columnType) + { + if(returnType == null) + { + returnType = new LazyType(); + } + returnType.RealType = columnType; + return returnType; + } public bool HasArguments { get { return true; } @@ -41,12 +53,13 @@ string typeName = args[1].ToString(); string sqlType; IType hqlType = TypeFactory.HeuristicType(typeName); + SetLazyType(hqlType); if (hqlType != null) { SqlType[] sqlTypeCodes = hqlType.SqlTypes(factory); if (sqlTypeCodes.Length != 1) { - throw new QueryException("invalid Hibernate type for cast()"); + throw new QueryException("invalid NHibernate type for cast(), was:" + typeName); } sqlType = factory.Dialect.GetCastTypeName(sqlTypeCodes[0]); if (sqlType == null) @@ -92,5 +105,217 @@ } #endregion + + /// <summary> + /// Delegate the values to a real type + /// </summary> + /// <remarks> + /// The real return type of Cast is know only after the Cast is parsed. + /// This class was created in NH to remove the responsibility of the parser about know the + /// real return type. + /// </remarks> + [Serializable] + private class LazyType: IType + { + public IType RealType { get; set; } + + #region Implementation of ICacheAssembler + + public object Disassemble(object value, ISessionImplementor session, object owner) + { + return RealType.Disassemble(value, session, owner); + } + + public object Assemble(object cached, ISessionImplementor session, object owner) + { + return RealType.Assemble(cached, session, owner); + } + + public void BeforeAssemble(object cached, ISessionImplementor session) + { + RealType.BeforeAssemble(cached, session); + } + + #endregion + + #region Implementation of IType + + public string Name + { + get { return RealType.Name; } + } + + public System.Type ReturnedClass + { + get { return RealType.ReturnedClass; } + } + + public bool IsMutable + { + get { return RealType.IsMutable; } + } + + public bool IsAssociationType + { + get { return RealType.IsAssociationType; } + } + + public bool IsXMLElement + { + get { return RealType.IsXMLElement; } + } + + public bool IsCollectionType + { + get { return RealType.IsCollectionType; } + } + + public bool IsComponentType + { + get { return RealType.IsComponentType; } + } + + public bool IsEntityType + { + get { return RealType.IsEntityType; } + } + + public bool IsAnyType + { + get { return RealType.IsAnyType; } + } + + public SqlType[] SqlTypes(IMapping mapping) + { + return RealType.SqlTypes(mapping); + } + + public int GetColumnSpan(IMapping mapping) + { + return RealType.GetColumnSpan(mapping); + } + + public bool IsDirty(object old, object current, ISessionImplementor session) + { + return RealType.IsDirty(old, current, session); + } + + public bool IsDirty(object old, object current, bool[] checkable, ISessionImplementor session) + { + return RealType.IsDirty(old, current, checkable, session); + } + + public bool IsModified(object oldHydratedState, object currentState, bool[] checkable, ISessionImplementor session) + { + return RealType.IsModified(oldHydratedState, currentState, checkable, session); + } + + public object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) + { + return RealType.NullSafeGet(rs, names, session, owner); + } + + public object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) + { + return RealType.NullSafeGet(rs, name, session, owner); + } + + public void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session) + { + RealType.NullSafeSet(st, value, index, settable, session); + } + + public void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) + { + RealType.NullSafeSet(st, value, index, session); + } + + public string ToLoggableString(object value, ISessionFactoryImplementor factory) + { + return RealType.ToLoggableString(value, factory); + } + + public object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImplementor factory) + { + return RealType.DeepCopy(val, entityMode, factory); + } + + public object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) + { + return RealType.Hydrate(rs, names, session, owner); + } + + public object ResolveIdentifier(object value, ISessionImplementor session, object owner) + { + return RealType.ResolveIdentifier(value, session, owner); + } + + public object SemiResolve(object value, ISessionImplementor session, object owner) + { + return RealType.SemiResolve(value, session, owner); + } + + public object Replace(object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready) + { + return RealType.Replace(original, target, session, owner, copiedAlready); + } + + public object Replace(object original, object target, ISessionImplementor session, object owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection) + { + return RealType.Replace(original, target, session, owner, copyCache, foreignKeyDirection); + } + + public bool IsSame(object x, object y, EntityMode entityMode) + { + return RealType.IsSame(x, y, entityMode); + } + + public bool IsEqual(object x, object y, EntityMode entityMode) + { + return RealType.IsEqual(x, y, entityMode); + } + + public bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory) + { + return RealType.IsEqual(x, y, entityMode, factory); + } + + public int GetHashCode(object x, EntityMode entityMode) + { + return RealType.GetHashCode(x, entityMode); + } + + public int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory) + { + return RealType.GetHashCode(x, entityMode, factory); + } + + public int Compare(object x, object y, EntityMode? entityMode) + { + return RealType.Compare(x, y, entityMode); + } + + public IType GetSemiResolvedType(ISessionFactoryImplementor factory) + { + return RealType.GetSemiResolvedType(factory); + } + + public void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) + { + RealType.SetToXMLNode(node, value, factory); + } + + public object FromXMLNode(XmlNode xml, IMapping factory) + { + return RealType.FromXMLNode(xml, factory); + } + + public bool[] ToColumnNullness(object value, IMapping mapping) + { + return RealType.ToColumnNullness(value, mapping); + } + + #endregion + } } } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-04-22 19:45:48 UTC (rev 4199) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-04-22 22:12:41 UTC (rev 4200) @@ -3,6 +3,7 @@ using NHibernate.Dialect; using NHibernate.Dialect.Function; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.Hql { @@ -413,13 +414,13 @@ if(!IsOracleDialect()) { hql1 = "select nullif(h.NickName, '1e1') from Human h"; - hql2 = "from Human h where nullif(h.NickName, '1e1') not is null"; + hql2 = "from Human h where not(nullif(h.NickName, '1e1') is null)"; } else { // Oracle need same specific types hql1 = "select nullif(str(h.NickName), '1e1') from Human h"; - hql2 = "from Human h where nullif(str(h.NickName), '1e1') not is null"; + hql2 = "from Human h where not (nullif(str(h.NickName), '1e1') is null)"; } // test only the parser and render using (ISession s = OpenSession()) @@ -576,18 +577,18 @@ string hql; IList l; Animal result; - + double expectedBodyWeight = 1.3; // Rendered in SELECT using a property hql = "select cast(a.BodyWeight as Double) from Animal a"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3f, l[0]); + Assert.That(l[0], Is.TypeOf(typeof (double))); // Rendered in SELECT using a property in an operation with costant hql = "select cast(7+123-5*a.BodyWeight as Double) from Animal a"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(7f + 123f - 5f * 1.3f, l[0]); + Assert.AreEqual(7 + 123 - 5 * 1.3d, l[0]); // Rendered in SELECT using a property and nested functions if (!(Dialect is Oracle8iDialect)) @@ -595,7 +596,7 @@ hql = "select cast(cast(a.BodyWeight as string) as Double) from Animal a"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3F, l[0]); + Assert.That(l[0], Is.TypeOf(typeof(double))); } // TODO: Rendered in SELECT using string costant assigned with critic chars (separators) @@ -632,13 +633,13 @@ hql = "select cast(a.BodyWeight as Double) from Animal a group by cast(a.BodyWeight as Double)"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3f, l[0]); + Assert.That(l[0], Is.TypeOf(typeof(double))); // Rendered in GROUP BY using a property in an operation with costant hql = "select cast(7+123-5*a.BodyWeight as Double) from Animal a group by cast(7+123-5*a.BodyWeight as Double)"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(7f + 123f - 5f * 1.3f, l[0]); + Assert.AreEqual(7 + 123 - 5 * 1.3d, l[0]); // Rendered in GROUP BY using a property and nested functions if (!(Dialect is Oracle8iDialect)) @@ -647,14 +648,14 @@ "select cast(cast(a.BodyWeight as string) as Double) from Animal a group by cast(cast(a.BodyWeight as string) as Double)"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3F, l[0]); + Assert.That(l[0], Is.TypeOf(typeof(double))); } // Rendered in HAVING using a property hql = "select cast(a.BodyWeight as Double) from Animal a group by cast(a.BodyWeight as Double) having cast(a.BodyWeight as Double)>0"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3f, l[0]); + Assert.That(l[0], Is.TypeOf(typeof(double))); // Rendered in HAVING using a property in an operation with costants hql = "select cast(7+123.3-1*a.BodyWeight as int) from Animal a group by cast(7+123.3-1*a.BodyWeight as int) having cast(7+123.3-1*a.BodyWeight as int)>0"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-23 03:28:40
|
Revision: 4202 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4202&view=rev Author: fabiomaulo Date: 2009-04-23 03:28:22 +0000 (Thu, 23 Apr 2009) Log Message: ----------- - Bug fix + refactoring AST qt - test to pass Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-22 22:56:16 UTC (rev 4201) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-23 03:28:22 UTC (rev 4202) @@ -4,6 +4,7 @@ using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Hql.Util; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; @@ -251,22 +252,7 @@ /// <returns>The defined persister for this class, or null if none found.</returns> public static IQueryable FindQueryableUsingImports(ISessionFactoryImplementor sfi, string className) { - // NH : this method prevent unrecognized class when entityName != class.FullName - // this is a patch for the TODO below - var possibleResult = sfi.TryGetEntityPersister(GetEntityName(className)) as IQueryable; - if (possibleResult != null) - { - return possibleResult; - } - - string importedClassName = sfi.GetImportedClassName(className); - - if (importedClassName == null) - { - return null; - } - // NH: This method don't work if entityName != class.FullName - return (IQueryable)sfi.TryGetEntityPersister(GetEntityName(importedClassName)); + return SessionFactoryHelper.FindQueryableUsingImports(sfi, className); } private static string GetEntityName(string assemblyQualifiedName) @@ -292,24 +278,7 @@ /// <returns>The defined persister for this entity, or null if none found.</returns> private IEntityPersister FindEntityPersisterByName(string name) { - // First, try to get the persister using the given name directly. - try - { - return _sfi.GetEntityPersister( name ); - } - catch (MappingException) - { - // unable to locate it using this name - } - - // If that didn't work, try using the 'import' name. - string importedClassName = _sfi.GetImportedClassName( name ); - if ( importedClassName == null ) - { - return null; - } - - return _sfi.GetEntityPersister( importedClassName ); + return SessionFactoryHelper.FindEntityPersisterUsingImports(_sfi, name); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs 2009-04-22 22:56:16 UTC (rev 4201) +++ trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs 2009-04-23 03:28:22 UTC (rev 4202) @@ -11,21 +11,26 @@ { public static IQueryable FindQueryableUsingImports(ISessionFactoryImplementor sfi, string className) { + return FindEntityPersisterUsingImports(sfi, className) as IQueryable; + } + + public static IEntityPersister FindEntityPersisterUsingImports(ISessionFactoryImplementor sfi, string className) + { // NH : short cut - if(string.IsNullOrEmpty(className)) + if (string.IsNullOrEmpty(className)) { return null; } - - if(!char.IsLetter(className[0]) && !className[0].Equals('_')) + + if (!char.IsLetter(className[0]) && !className[0].Equals('_')) { - return null; + return null; } // NH : this method prevent unrecognized class when entityName != class.FullName // this is a patch for the TODO below - var possibleResult = sfi.TryGetEntityPersister(GetEntityName(className)) as IQueryable; - if(possibleResult != null) + var possibleResult = sfi.TryGetEntityPersister(GetEntityName(className)); + if (possibleResult != null) { return possibleResult; } @@ -37,7 +42,7 @@ return null; } // NH: This method don't work if entityName != class.FullName - return (IQueryable)sfi.TryGetEntityPersister(GetEntityName(importedClassName)); + return sfi.TryGetEntityPersister(GetEntityName(importedClassName)); } private static string GetEntityName(string assemblyQualifiedName) Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs 2009-04-23 03:28:22 UTC (rev 4202) @@ -0,0 +1,47 @@ +using System.Collections; +using NHibernate.Hql.Ast.ANTLR; +using System.Collections.Generic; +using NHibernate.Util; + +namespace NHibernate.Test.HQL.Ast +{ + public class BaseFixture: TestCase + { + private readonly IDictionary<string, IFilter> emptyfilters = new CollectionHelper.EmptyMapClass<string, IFilter>(); + + #region Overrides of TestCase + + protected override IList Mappings + { + get { return new string[0]; } + } + + #endregion + + protected override void Configure(Cfg.Configuration configuration) + { + var assembly = GetType().Assembly; + string mappingNamespace = GetType().Namespace; + foreach (var resource in assembly.GetManifestResourceNames()) + { + if (resource.StartsWith(mappingNamespace) && resource.EndsWith(".hbm.xml")) + { + configuration.AddResource(resource, assembly); + } + } + } + + public string GetSql(string query) + { + var qt = new QueryTranslatorImpl(null, query, emptyfilters, sessions); + qt.Compile(null, false); + return qt.SQLString; + } + + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory; + } + + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs 2009-04-23 03:28:22 UTC (rev 4202) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.HQL.Ast +{ + public class SimpleClass + { + public virtual string Description { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml 2009-04-23 03:28:22 UTC (rev 4202) @@ -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.HQL.Ast"> + + <class name="SimpleClass"> + <id type="int"> + <generator class="native" /> + </id> + <property name="Description"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs 2009-04-23 03:28:22 UTC (rev 4202) @@ -0,0 +1,17 @@ +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.HQL.Ast +{ + [TestFixture] + public class SqlTranslationFixture : BaseFixture + { + [Test, Ignore("Bug not fixed yet")] + public void ParseFloatConstant() + { + var query = "select 123.5, s from SimpleClass s"; + + Assert.That(GetSql(query), Text.StartsWith("select 123.5")); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-22 22:56:16 UTC (rev 4201) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-23 03:28:22 UTC (rev 4202) @@ -291,7 +291,10 @@ <Compile Include="GenericTest\SetGeneric\B.cs" /> <Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" /> <Compile Include="HQL\Animal.cs" /> + <Compile Include="HQL\Ast\BaseFixture.cs" /> <Compile Include="HQL\Ast\ParsingFixture.cs" /> + <Compile Include="HQL\Ast\SimpleClass.cs" /> + <Compile Include="HQL\Ast\SqlTranslationFixture.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" /> @@ -1716,6 +1719,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="HQL\Ast\SimpleClass.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\TestQueries.xml" /> <EmbeddedResource Include="HQL\Ast\TestQueriesWithResults.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1741\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-23 04:17:54
|
Revision: 4203 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4203&view=rev Author: fabiomaulo Date: 2009-04-23 04:17:31 +0000 (Thu, 23 Apr 2009) Log Message: ----------- Bug fixed Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-04-23 03:28:22 UTC (rev 4202) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-04-23 04:17:31 UTC (rev 4203) @@ -1,4 +1,5 @@ using System; +using System.Globalization; using log4net; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Persister.Entity; @@ -178,11 +179,11 @@ Decimal number; try { - number = Decimal.Parse(literalValue); + number = Decimal.Parse(literalValue, NumberFormatInfo.InvariantInfo); } catch (Exception t) { - throw new HibernateException("Could not parse literal [" + text + "] as big-decimal", t); + throw new HibernateException("Could not parse literal [" + text + "] as System.Decimal.", t); } return _formatters[DECIMAL_LITERAL_FORMAT].Format(number); @@ -330,7 +331,7 @@ { public string Format(Decimal number) { - return number.ToString(); + return number.ToString(NumberFormatInfo.InvariantInfo); } } @@ -347,7 +348,7 @@ } catch (Exception t) { - throw new HibernateException("Unable to format decimal literal in approximate format [" + number.ToString() + "]", t); + throw new HibernateException("Unable to format decimal literal in approximate format [" + number.ToString(NumberFormatInfo.InvariantInfo) + "]", t); } } } Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs 2009-04-23 03:28:22 UTC (rev 4202) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs 2009-04-23 04:17:31 UTC (rev 4203) @@ -2,6 +2,7 @@ using NHibernate.Hql.Ast.ANTLR; using System.Collections.Generic; using NHibernate.Util; +using NUnit.Framework; namespace NHibernate.Test.HQL.Ast { @@ -9,6 +10,14 @@ { private readonly IDictionary<string, IFilter> emptyfilters = new CollectionHelper.EmptyMapClass<string, IFilter>(); + protected override void OnSetUp() + { + if (!(sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory)) + { + Assert.Ignore("ASTQueryTranslator specific test"); + } + } + #region Overrides of TestCase protected override IList Mappings @@ -37,11 +46,5 @@ qt.Compile(null, false); return qt.SQLString; } - - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory; - } - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs 2009-04-23 03:28:22 UTC (rev 4202) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs 2009-04-23 04:17:31 UTC (rev 4203) @@ -6,10 +6,10 @@ [TestFixture] public class SqlTranslationFixture : BaseFixture { - [Test, Ignore("Bug not fixed yet")] + [Test] public void ParseFloatConstant() { - var query = "select 123.5, s from SimpleClass s"; + const string query = "select 123.5, s from SimpleClass s"; Assert.That(GetSql(query), Text.StartsWith("select 123.5")); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-23 06:03:29
|
Revision: 4206 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4206&view=rev Author: fabiomaulo Date: 2009-04-23 06:03:26 +0000 (Thu, 23 Apr 2009) Log Message: ----------- - Refactoring, bug fix of AST QT - commented test not present in H3.2 and unneeded because wrong Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.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.Test/Legacy/FooBarTest.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-23 04:46:55 UTC (rev 4205) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-23 06:03:26 UTC (rev 4206) @@ -2,7 +2,6 @@ using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Parameters; -using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Type; using NHibernate.Util; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-04-23 04:46:55 UTC (rev 4205) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-04-23 06:03:26 UTC (rev 4206) @@ -14,6 +14,7 @@ /// </summary> public class SelectClause : SelectExpressionList { + private const string JoinFetchWithoutOwnerExceptionMsg = "Query specified join fetching, but the owner of the fetched association was not present in the select list [{0}]"; private bool _prepared; private bool _scalarSelect; private List<FromElement> _collectionFromElements; @@ -196,12 +197,9 @@ origin = fromElement.RealOrigin; } - if ( !_fromElementsForLoad.Contains( origin ) ) { - throw new QueryException( - "query specified join fetching, but the owner " + - "of the fetched association was not present in the select list " + - "[" + fromElement.GetDisplayText() + "]" - ); + if (!_fromElementsForLoad.Contains(origin)) + { + throw new QueryException(string.Format(JoinFetchWithoutOwnerExceptionMsg, fromElement.GetDisplayText())); } IType type = fromElement.SelectType; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-04-23 04:46:55 UTC (rev 4205) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-04-23 06:03:26 UTC (rev 4206) @@ -25,21 +25,21 @@ // are not select expressions (e.g. DISTINCT). IASTNode firstChild = GetFirstSelectExpression(); IASTNode parent = this; - List<ISelectExpression> list = new List<ISelectExpression>(parent.ChildCount); + var list = new List<ISelectExpression>(parent.ChildCount); - for (int i = firstChild.ChildIndex; i < this.ChildCount; i++) + for (IASTNode n = firstChild; n != null; n = n.NextSibling) { - IASTNode n = GetChild(i); - - if ( n is ISelectExpression ) + var se = n as ISelectExpression; + if (se != null) { - list.Add((ISelectExpression)n); + list.Add(se); } - else + else { - throw new InvalidOperationException( "Unexpected AST: " + n.GetType().Name + " " + new ASTPrinter().ShowAsString( n, "" ) ); + throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + new ASTPrinter().ShowAsString(n, "")); } } + return list.ToArray(); } Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-04-23 04:46:55 UTC (rev 4205) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2009-04-23 06:03:26 UTC (rev 4206) @@ -2468,9 +2468,14 @@ s.CreateQuery("select count(*) from Bar as bar where 1 in indices(bar.Baz.FooArray)").List(); s.CreateQuery( "select count(*) from Bar as bar where '1' in (from bar.Component.Glarch.ProxyArray g where g.Name='foo')").List(); - s.CreateQuery( - "select count(*) from Bar as bar where '1' in (from g in bar.Component.Glarch.ProxyArray.elements where g.Name='foo')") - .List(); + + // The nex query is wrong and is not present in H3.2: + // The SQL result, from Classic parser, is the same of the previous query. + // The AST parser has some problem to parse 'from g in bar.Component.Glarch.ProxyArray' + // which should be parsed as 'from bar.Component.Glarch.ProxyArray g' + //s.CreateQuery( + // "select count(*) from Bar as bar where '1' in (from g in bar.Component.Glarch.ProxyArray.elements where g.Name='foo')") + // .List(); // TODO: figure out why this is throwing an ORA-1722 error // probably the conversion ProxyArray.id (to_number ensuring a not null value) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-24 06:40:22
|
Revision: 4210 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4210&view=rev Author: fabiomaulo Date: 2009-04-24 06:40:17 +0000 (Fri, 24 Apr 2009) Log Message: ----------- Fix NH-1742 by Richard Brown Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-04-24 06:17:30 UTC (rev 4209) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-04-24 06:40:17 UTC (rev 4210) @@ -713,7 +713,7 @@ { for (int index = 0; index < namedParameterLocations.Count; index++) { - if (namedParameterLocations[index] == existingParameterLocation) + if (namedParameterLocations[index] >= existingParameterLocation) namedParameterLocations[index]++; } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs 2009-04-24 06:40:17 UTC (rev 4210) @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1742 +{ + public class Event + { + private readonly IList<Description> descriptions = new List<Description>(); + + public virtual IList<Description> Descriptions + { + get { return descriptions; } + } + + public virtual int ID { get; set; } + public virtual Device SendedBy { get; set; } + public virtual DateTime Date { get; set; } + } + + public class Device + { + public virtual int ID { get; set; } + } + + public class Description + { + public virtual Event Event { get; set; } + public virtual int ID { get; set; } + public virtual string LanguageID { get; set; } + public virtual string Value { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs 2009-04-24 06:40:17 UTC (rev 4210) @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1742 +{ + [TestFixture] + public class Fixture : BugTestCase + { + private ISession session; + private ITransaction transaction; + private Device device; + private DateTime date = new DateTime(2000, 1, 1); + + protected override void OnSetUp() + { + base.OnSetUp(); + + session = OpenSession(); + transaction = session.BeginTransaction(); + + device = new Device(); + session.Save(device); + + var ev = new Event {Date = date, SendedBy = device}; + session.Save(ev); + + var d = new Description {Event = ev, Value = "Test", LanguageID = "it"}; + session.Save(d); + + IFilter f = session.EnableFilter("LanguageFilter").SetParameter("LanguageID", "it"); + + f.Validate(); + } + + protected override void OnTearDown() + { + transaction.Rollback(); + session.Close(); + + base.OnTearDown(); + } + + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect as MsSql2000Dialect != null; + } + + [Test] + public void BugTest() + { + IQuery query = + session.CreateQuery("SELECT e FROM Event e " + " inner join fetch e.descriptions d " + + " WHERE (e.SendedBy in( :dev)) " + " AND (e.Date >= :from) " + " AND (e.Date <= :to)" + + " ORDER BY d.Value"); + + var devices = new List<Device> {device}; + + query.SetParameterList("dev", devices).SetDateTime("from", date).SetDateTime("to", date.AddMonths(1)); + + Assert.AreEqual(1, query.List<Event>().Count); + } + + [Test] + public void WorkingTest() + { + IQuery query = + session.CreateQuery("SELECT e FROM Event e " + " inner join fetch e.descriptions d " + " WHERE (e.Date >= :from) " + + " AND (e.Date <= :to)" + " AND (e.SendedBy in( :dev)) " + " ORDER BY d.Value"); + + var devices = new List<Device> {device}; + + query.SetParameterList("dev", devices).SetDateTime("from", date).SetDateTime("to", date.AddMonths(1)); + + Assert.AreEqual(1, query.List<Event>().Count); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml 2009-04-24 06:40:17 UTC (rev 4210) @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1742" + default-lazy="false"> + + <class name="Event" table="tblEventi" > + <id name="ID" column="ID"> + <generator class="identity" /> + </id> + <many-to-one name="SendedBy" column="IDStrumento" class="Device" + access="property" /> + <property name="Date" column="Data"/> + <bag name="descriptions" lazy="false" access="field" inverse="true" cascade="none" > + <key column="IDEvento" /> + <one-to-many class="Description" /> + <filter name="LanguageFilter" condition=":LanguageID = IDLingua"/> + </bag> + </class> + + <class name="Device" table="tblStrumenti"> + <id name="ID" column="ID" type="Int32" unsaved-value="0"> + <generator class="identity" /> + </id> + </class> + + <class name="Description" table="tblDescrizioni"> + <id name="ID" column="ID"> + <generator class="identity" /> + </id> + <many-to-one name="Event" column="IDEvento" class="Event" + access="property" /> + <property name="Value" column="Descrizione"/> + <property name="LanguageID" column="IDLingua"/> + <filter name="LanguageFilter" condition=":LanguageID = IDLingua"/> + </class> + + <filter-def name="LanguageFilter"> + <filter-param name="LanguageID" type="String"/> + </filter-def> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-24 06:17:30 UTC (rev 4209) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-24 06:40:17 UTC (rev 4210) @@ -326,6 +326,8 @@ <Compile Include="NHSpecificTest\NH1716\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1741\Domain.cs" /> <Compile Include="NHSpecificTest\NH1741\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1742\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1742\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1719,6 +1721,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1742\Mappings.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\SimpleClass.hbm.xml" /> <EmbeddedResource Include="HQL\Ast\TestQueries.xml" /> <EmbeddedResource Include="HQL\Ast\TestQueriesWithResults.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-29 22:09:11
|
Revision: 4216 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4216&view=rev Author: fabiomaulo Date: 2009-04-29 22:09:01 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Starting executable HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/IStatementExecutor.cs 2009-04-29 22:09:01 UTC (rev 4216) @@ -0,0 +1,23 @@ +using NHibernate.Engine; +using NHibernate.SqlCommand; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + /// <summary> + /// Encapsulates the strategy required to execute various types of update, delete, + /// and insert statements issued through HQL. + /// </summary> + public interface IStatementExecutor + { + SqlString[] SqlStatements { get; } + + /// <summary> + /// Execute the sql managed by this executor using the given parameters. + /// </summary> + /// <param name="parameters">Essentially bind information for this processing. </param> + /// <param name="session">The session originating the request. </param> + /// <returns> The number of entities updated/deleted. </returns> + /// <exception cref="HibernateException"/> + int Execute(QueryParameters parameters, ISessionImplementor session); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 21:10:10 UTC (rev 4215) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 22:09:01 UTC (rev 4216) @@ -480,6 +480,7 @@ <Compile Include="Hql\Ast\ANTLR\CollectionProperties.cs" /> <Compile Include="Hql\Ast\ANTLR\DetailedSemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\ErrorCounter.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-30 17:54:12
|
Revision: 4217 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4217&view=rev Author: fabiomaulo Date: 2009-04-30 17:54:10 +0000 (Thu, 30 Apr 2009) Log Message: ----------- continue work on executable HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -0,0 +1,23 @@ +using NHibernate.Engine; +using NHibernate.SqlCommand; +using log4net; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public abstract class AbstractStatementExecutor : IStatementExecutor + { + private readonly ILog log; + + protected AbstractStatementExecutor(HqlSqlWalker walker, ILog log) + { + Walker = walker; + this.log = log; + } + + protected HqlSqlWalker Walker { get; private set; } + + public abstract SqlString[] SqlStatements{get;} + + public abstract int Execute(QueryParameters parameters, ISessionImplementor session); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using Antlr.Runtime; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public class BasicExecutor : AbstractStatementExecutor + { + private readonly IQueryable persister; + private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); + private SqlString sql; + + public BasicExecutor(HqlSqlWalker walker, IQueryable persister) : base(walker, log) + { + this.persister = persister; + try + { + + //SqlGenerator gen = new SqlGenerator(Factory); + //gen.statement(walker.getAST()); + //sql = gen.GetSQL(); + //gen.ParseErrorHandler.ThrowQueryException(); + } + catch (RecognitionException e) + { + throw QuerySyntaxException.Convert(e); + } + } + + protected ISessionFactoryImplementor Factory + { + get + { + return Walker.SessionFactoryHelper.Factory; + } + } + + public override SqlString[] SqlStatements + { + get { return new[] {sql}; } + } + + public override int Execute(QueryParameters parameters, ISessionImplementor session) + { + //CoordinateSharedCacheCleanup(session); + + IDbCommand st = null; + RowSelection selection = parameters.RowSelection; + + try + { + try + { + //st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes); + IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + int pos = 1; + while (paramSpecifications.MoveNext()) + { + var paramSpec = paramSpecifications.Current; + pos += paramSpec.Bind(st, parameters, session, pos); + } + if (selection != null) + { + if (selection.Timeout != RowSelection.NoValue) + { + st.CommandTimeout = selection.Timeout; + } + } + return session.Batcher.ExecuteNonQuery(st); + } + finally + { + if (st != null) + { + session.Batcher.CloseCommand(st, null); + } + } + } + catch (DbException sqle) + { + throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, + "could not execute update query", sql); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-29 22:09:01 UTC (rev 4216) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 17:54:10 UTC (rev 4217) @@ -6,10 +6,12 @@ using Iesi.Collections.Generic; using log4net; using NHibernate.Engine; +using NHibernate.Hql.Ast.ANTLR.Exec; using NHibernate.Hql.Ast.ANTLR.Loader; using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -27,8 +29,10 @@ private IDictionary<string, IFilter> _enabledFilters; private readonly ISessionFactoryImplementor _factory; private QueryLoader _queryLoader; - private ParameterTranslationsImpl _paramTranslations; - + private IStatementExecutor statementExecutor; + private IStatement sqlAst; + private ParameterTranslationsImpl _paramTranslations; + private IDictionary<string, string> tokenReplacements; private HqlParseEngine _parser; private HqlSqlTranslator _translator; private HqlSqlGenerator _generator; @@ -202,7 +206,7 @@ public IStatement SqlAST { - get { return _translator.SqlStatement; } + get { return sqlAst; } } public IList<IParameterSpecification> CollectedParameterSpecifications @@ -322,27 +326,21 @@ return; } - if (replacements == null) - { - replacements = new Dictionary<string, string>(); - } + // Remember the parameters for the compilation. + tokenReplacements = replacements ?? new Dictionary<string, string>(1); _shallowQuery = shallow; try { // PHASE 1 : Parse the HQL into an AST. - if (_parser == null) - { - _parser = new HqlParseEngine(_hql, true, _factory); - _parser.Parse(); - } + HqlParseEngine parser = Parse(true); // PHASE 2 : Analyze the HQL AST, and produce an SQL AST. - _translator = new HqlSqlTranslator(_parser.Ast, _parser.Tokens, this, _factory, replacements, - collectionRole); - _translator.Translate(); - + HqlSqlWalker w = Analyze(parser, collectionRole); + + sqlAst = (IStatement)w.statement().Tree; + // at some point the generate phase needs to be moved out of here, // because a single object-level DML might spawn multiple SQL DML // command executions. @@ -356,16 +354,15 @@ if (_translator.SqlStatement.NeedsExecutor) { - throw new NotImplementedException(); // DML -// statementExecutor = buildAppropriateStatementExecutor( w ); + statementExecutor = BuildAppropriateStatementExecutor(w); } else { // PHASE 3 : Generate the SQL. - _generator = new HqlSqlGenerator(_translator.SqlStatement, _parser.Tokens, _factory); + _generator = new HqlSqlGenerator(_translator.SqlStatement, parser.Tokens, _factory); _generator.Generate(); - - _queryLoader = new QueryLoader( this, _factory, _translator.SqlStatement.Walker.SelectClause ); + + _queryLoader = new QueryLoader(this, _factory, w.SelectClause); } _compiled = true; @@ -389,6 +386,70 @@ _enabledFilters = null; //only needed during compilation phase... } + private IStatementExecutor BuildAppropriateStatementExecutor(HqlSqlWalker walker) + { + if (walker.StatementType == HqlSqlWalker.DELETE) + { + FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); + IQueryable persister = fromElement.Queryable; + if (persister.IsMultiTable) + { + throw new NotSupportedException(); + //return new MultiTableDeleteExecutor(walker); + } + else + { + return new BasicExecutor(walker, persister); + } + } + else if (walker.StatementType == HqlSqlWalker.UPDATE) + { + FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); + IQueryable persister = fromElement.Queryable; + if (persister.IsMultiTable) + { + // even here, if only properties mapped to the "base table" are referenced + // in the set and where clauses, this could be handled by the BasicDelegate. + // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate + throw new NotSupportedException(); + //return new MultiTableUpdateExecutor(walker); + } + else + { + return new BasicExecutor(walker, persister); + } + } + else if (walker.StatementType == HqlSqlWalker.INSERT) + { + //var statement = (IStatement)walker.statement().Tree; + + throw new QueryException("Unexpected statement type"); + } + else + { + throw new QueryException("Unexpected statement type"); + } + } + + private HqlSqlWalker Analyze(HqlParseEngine parser, string collectionRole) + { + _translator = new HqlSqlTranslator(parser.Ast, parser.Tokens, this, _factory, tokenReplacements, + collectionRole); + _translator.Translate(); + + return _translator.SqlStatement.Walker; + } + + private HqlParseEngine Parse(bool isFilter) + { + if (_parser == null) + { + _parser = new HqlParseEngine(_hql, isFilter, _factory); + _parser.Parse(); + } + return _parser; + } + private void ErrorIfDML() { if (_translator.SqlStatement.NeedsExecutor) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-29 22:09:01 UTC (rev 4216) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 17:54:10 UTC (rev 4217) @@ -480,6 +480,8 @@ <Compile Include="Hql\Ast\ANTLR\CollectionProperties.cs" /> <Compile Include="Hql\Ast\ANTLR\DetailedSemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\ErrorCounter.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\AbstractStatementExecutor.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\BasicExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Tuna T. <te...@gm...> - 2009-04-30 17:56:41
|
What is executable hql? Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Apr 30, 2009 at 8:54 PM, <fab...@us...> wrote: > executable HQL > |
From: <fab...@us...> - 2009-04-30 18:44:57
|
Revision: 4218 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4218&view=rev Author: fabiomaulo Date: 2009-04-30 18:44:49 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Starting executable HQL (Delete) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,37 @@ +using System; +using Antlr.Runtime; +using log4net; + +namespace NHibernate.Hql.Ast.ANTLR.Tree +{ + /// <summary> + /// Defines a top-level AST node representing an HQL delete statement. + /// </summary> + [Serializable] + public class DeleteStatement : AbstractRestrictableStatement + { + private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); + + public DeleteStatement(IToken token) : base(token) {} + + public override bool NeedsExecutor + { + get { return true; } + } + + public override int StatementType + { + get { return HqlSqlWalker.DELETE; } + } + + protected override ILog GetLog() + { + return log; + } + + protected override int GetWhereClauseParentTokenType() + { + return HqlSqlWalker.FROM; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 17:54:10 UTC (rev 4217) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 18:44:49 UTC (rev 4218) @@ -528,6 +528,7 @@ <Compile Include="Hql\Ast\ANTLR\Tree\CollectionFunction.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\ConstructorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\CountNode.cs" /> + <Compile Include="Hql\Ast\ANTLR\Tree\DeleteStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\DotNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\FromClause.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\FromElement.cs" /> Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,47 @@ +using System.Collections; +using NHibernate.Hql.Ast.ANTLR; +using System.Collections.Generic; +using NHibernate.Util; +using NHibernate.Hql.Classic; + +namespace NHibernate.Test.BulkManipulation +{ + public class BaseFixture: TestCase + { + private readonly IDictionary<string, IFilter> emptyfilters = new CollectionHelper.EmptyMapClass<string, IFilter>(); + + protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) + { + return !(factory.Settings.QueryTranslatorFactory is ClassicQueryTranslatorFactory); + } + + #region Overrides of TestCase + + protected override IList Mappings + { + get { return new string[0]; } + } + + #endregion + + protected override void Configure(Cfg.Configuration configuration) + { + var assembly = GetType().Assembly; + string mappingNamespace = GetType().Namespace; + foreach (var resource in assembly.GetManifestResourceNames()) + { + if (resource.StartsWith(mappingNamespace) && resource.EndsWith(".hbm.xml")) + { + configuration.AddResource(resource, assembly); + } + } + } + + public string GetSql(string query) + { + var qt = new QueryTranslatorImpl(null, query, emptyfilters, sessions); + qt.Compile(null, false); + return qt.SQLString; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,34 @@ +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.BulkManipulation +{ + [TestFixture] + public class HqlBulkOperations: BaseFixture + { + [Test, Ignore("Not supported yet.")] + public void SimpleDelete() + { + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Save(new SimpleClass {Description = "simple1"}); + s.Save(new SimpleClass {Description = "simple2"}); + tx.Commit(); + } + + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.CreateQuery("delete from SimpleClass").ExecuteUpdate(); + tx.Commit(); + } + + using (var s = OpenSession()) + { + var l = s.CreateQuery("from SimpleClass").List(); + Assert.That(l.Count, Is.EqualTo(0)); + } + } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.cs 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.BulkManipulation +{ + public class SimpleClass + { + public virtual string Description { get; set; } + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml (from rev 4216, trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-04-30 18:44:49 UTC (rev 4218) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.BulkManipulation"> + + <class name="SimpleClass"> + <id type="int"> + <generator class="native" /> + </id> + <property name="Description"/> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-30 17:54:10 UTC (rev 4217) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-30 18:44:49 UTC (rev 4218) @@ -81,6 +81,9 @@ <Compile Include="AssemblyInfo.cs" /> <Compile Include="Assertions\InheritedAreMarkedSerializable.cs" /> <Compile Include="Assertions\IsSerializable.cs" /> + <Compile Include="BulkManipulation\BaseFixture.cs" /> + <Compile Include="BulkManipulation\HQLBulkOperations.cs" /> + <Compile Include="BulkManipulation\SimpleClass.cs" /> <Compile Include="Bytecode\Lightweight\BytecodeProviderFixture.cs" /> <Compile Include="Bytecode\WrongProxyFactoryFactory.cs" /> <Compile Include="CacheTest\CacheFixture.cs" /> @@ -1722,6 +1725,7 @@ <EmbeddedResource Include="Cascade\Job.hbm.xml" /> <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> + <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1727\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1742\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-04-30 23:41:34
|
Revision: 4219 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4219&view=rev Author: fabiomaulo Date: 2009-04-30 23:40:57 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Removing compilation Warnings about CLS compliant and some other about Equals+GetHashCode Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IBinaryOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IResolvableNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IRestrictableStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ISelectExpression.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IUnaryOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IsNotNullLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IsNullLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/LiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/OrderByClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UnaryArithmeticNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UnaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTAppender.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTUtil.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ColumnHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/IVisitationStrategy.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NodeTraverser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/PathHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate/LockMode.cs trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ /// Look ahead for tokenizing is all lowercase, whereas the original case of an input stream is preserved. /// Copied from http://www.antlr.org/wiki/pages/viewpage.action?pageId=1782 ///</summary> + [CLSCompliant(false)] public class CaseInsensitiveStringStream : ANTLRStringStream { public CaseInsensitiveStringStream(char[] data, int numberOfActualCharsInArray) : base(data, numberOfActualCharsInArray) { } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Text; using Antlr.Runtime; using log4net; @@ -8,6 +9,7 @@ /// <summary> /// An error handler that counts parsing errors and warnings. /// </summary> + [CLSCompliant(false)] public class ErrorCounter : IParseErrorHandler { private static readonly ILog log = LogManager.GetLogger(typeof(ErrorCounter)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,3 +1,4 @@ +using System; using NHibernate.Engine; using NHibernate.SqlCommand; using log4net; @@ -4,6 +5,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Exec { + [CLSCompliant(false)] public abstract class AbstractStatementExecutor : IStatementExecutor { private readonly ILog log; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Exec { + [CLSCompliant(false)] public class BasicExecutor : AbstractStatementExecutor { private readonly IQueryable persister; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlLexer.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,22 +1,21 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { - public partial class HqlLexer - { - public override IToken Emit() - { - HqlToken t = new HqlToken(input, - state.type, - state.channel, - state.tokenStartCharIndex, - CharIndex - 1); + [CLSCompliant(false)] + public partial class HqlLexer + { + public override IToken Emit() + { + var t = new HqlToken(input, + state.type, + state.channel, + state.tokenStartCharIndex, + CharIndex - 1) {Line = state.tokenStartLine, Text = state.text}; - t.Line = state.tokenStartLine; - t.Text = state.text; - - Emit(t); - return t; - } - } + Emit(t); + return t; + } + } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public partial class HqlParser { private static readonly ILog log = LogManager.GetLogger(typeof(HqlParser)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -14,6 +14,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public partial class HqlSqlWalker { private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlWalker)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,11 +1,13 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { /// <summary> /// A custom token class for the HQL grammar. /// </summary> - public class HqlToken : CommonToken + [CLSCompliant(false)] + public class HqlToken : CommonToken { /// <summary> /// The previous token type. Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IErrorReporter.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { @@ -7,6 +8,7 @@ /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public interface IErrorReporter { void ReportError(RecognitionException e); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/IParseErrorHandler.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,10 +1,13 @@ -namespace NHibernate.Hql.Ast.ANTLR +using System; + +namespace NHibernate.Hql.Ast.ANTLR { /// <summary> /// Defines the behavior of an error handler for the HQL parsers. /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public interface IParseErrorHandler : IErrorReporter { int GetErrorCount(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -19,6 +19,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Loader { + [CLSCompliant(false)] public class QueryLoader : BasicLoader { private readonly QueryTranslatorImpl _queryTranslator; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySyntaxException.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class QuerySyntaxException : QueryException { public QuerySyntaxException(string message) : base(message) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -18,6 +18,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class QueryTranslatorImpl : IFilterTranslator { private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); @@ -464,6 +465,7 @@ } } + [CLSCompliant(false)] public class HqlParseEngine { private static readonly ILog log = LogManager.GetLogger(typeof(HqlParseEngine)); @@ -579,6 +581,7 @@ } } + [CLSCompliant(false)] public class HqlSqlTranslator { private readonly IASTNode _inputAst; @@ -636,6 +639,7 @@ } } + [CLSCompliant(false)] public class HqlSqlGenerator { private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlGenerator)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -14,6 +14,7 @@ namespace NHibernate.Hql.Ast.ANTLR { + [CLSCompliant(false)] public class SessionFactoryHelperExtensions { private readonly ISessionFactoryImplementor _sfi; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -17,6 +17,7 @@ /// Author: Joshua Davis, Steve Ebersole /// Ported By: Steve Strong /// </summary> + [CLSCompliant(false)] public partial class SqlGenerator : IErrorReporter { /// <summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTFactory.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime.Tree; +using System; +using Antlr.Runtime.Tree; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTFactory : IASTFactory { private readonly ITreeAdaptor _adaptor; @@ -11,13 +13,17 @@ _adaptor = adaptor; } + #region IASTFactory Members + public IASTNode CreateNode(int type, string text, params IASTNode[] children) { - IASTNode parent = (IASTNode)_adaptor.Create(type, text); + var parent = (IASTNode) _adaptor.Create(type, text); parent.AddChildren(children); return parent; } + + #endregion } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTNode : IASTNode, ITree { private int _startIndex; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTTreeAdaptor.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,8 +1,10 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using Antlr.Runtime.Tree; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ASTTreeAdaptor : BaseTreeAdaptor { public override object DupNode(object t) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractNullnessCheckNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -13,6 +13,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public abstract class AbstractNullnessCheckNode : UnaryLogicOperatorNode { protected AbstractNullnessCheckNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractRestrictableStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,9 +1,11 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using log4net; using NHibernate.Hql.Ast.ANTLR.Util; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public abstract class AbstractRestrictableStatement : AbstractStatement, IRestrictableStatement { private FromClause _fromClause; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractSelectExpression.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,7 +1,9 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public abstract class AbstractSelectExpression : HqlSqlWalkerNode, ISelectExpression { private string _alias; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AbstractStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -9,6 +9,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public abstract class AbstractStatement : HqlSqlWalkerNode, IDisplayableNode, IStatement { protected AbstractStatement(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AggregateNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Type; using NHibernate.Hql.Ast.ANTLR.Util; @@ -10,6 +11,7 @@ /// Author: Joshua Davis /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class AggregateNode : AbstractSelectExpression, ISelectExpression { public AggregateNode(IToken token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BetweenOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,13 +1,13 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Contract for nodes representing logcial BETWEEN (ternary) operators. - * - * @author Steve Ebersole - */ + /// <summary> + /// Contract for nodes representing logcial BETWEEN (ternary) operators. + /// </summary> + [CLSCompliant(false)] public class BetweenOperatorNode : SqlNode, IOperatorNode { public BetweenOperatorNode(IToken token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryArithmeticOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -5,11 +5,10 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Nodes which represent binary arithmetic operators. - * - * @author Gavin King - */ + /// <summary> + /// Nodes which represent binary arithmetic operators. + /// </summary> + [CLSCompliant(false)] public class BinaryArithmeticOperatorNode : AbstractSelectExpression, IBinaryOperatorNode, IDisplayableNode { public BinaryArithmeticOperatorNode(IToken token) @@ -81,13 +80,13 @@ public override IType DataType { - /** - * Figure out the type of the binary expression by looking at - * the types of the operands. Sometimes we don't know both types, - * if, for example, one is a parameter. - */ get { + /* + * Figure out the type of the binary expression by looking at + * the types of the operands. Sometimes we don't know both types, + * if, for example, one is a parameter. + */ if (base.DataType == null) { base.DataType = ResolveDataType(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ /// Author: Steve Ebersole /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class BinaryLogicOperatorNode : HqlSqlWalkerNode, IBinaryOperatorNode { public BinaryLogicOperatorNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -5,11 +5,10 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Represents a boolean literal within a query. - * - * @author Steve Ebersole - */ + ///<summary> + /// Represents a boolean literal within a query. + ///</summary> + [CLSCompliant(false)] public class BooleanLiteralNode : LiteralNode, IExpectedTypeAwareNode { private IType expectedType; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/Case2Node.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,14 +1,14 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree { - /** - * Represents a case ... when .. then ... else ... end expression in a select. - * - * @author Gavin King - */ + /// <summary> + /// Represents a case ... when .. then ... else ... end expression in a select. + /// </summary> + [CLSCompliant(false)] public class Case2Node : AbstractSelectExpression, ISelectExpression { public Case2Node(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -1,4 +1,5 @@ -using Antlr.Runtime; +using System; +using Antlr.Runtime; using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Type; @@ -10,6 +11,7 @@ /// Author: Gavin King /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class CaseNode : AbstractSelectExpression, ISelectExpression { public CaseNode(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CollectionFunction.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -8,6 +8,7 @@ /// Author: josh /// Ported by: Steve strong /// </summary> + [CLSCompliant(false)] public class CollectionFunction : MethodNode, IDisplayableNode { public CollectionFunction(IToken token) : base(token) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -7,6 +7,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class ConstructorNode : SelectExpressionList, ISelectExpression { private IType[] _constructorArgumentTypes; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -8,6 +8,7 @@ /// Defines a top-level AST node representing an HQL delete statement. /// </summary> [Serializable] + [CLSCompliant(false)] public class DeleteStatement : AbstractRestrictableStatement { private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -17,6 +17,7 @@ /// Author: Joshua Davis /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class DotNode : FromReferenceNode, ISelectExpression { private static readonly ILog log = LogManager.GetLogger(typeof(DotNode)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ /// Author: josh /// Ported by: Steve Strong /// </summary> + [CLSCompliant(false)] public class FromClause : HqlSqlWalkerNode, IDisplayableNode { private static readonly ILog log = LogManager.GetLogger(typeof(FromClause)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -12,6 +12,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { + [CLSCompliant(false)] public class FromElement : HqlSqlWalkerNode, IDisplayableNode, IParameterContainer { private static readonly ILog log = LogManager.GetLogger(typeof(FromElement)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-04-30 18:44:49 UTC (rev 4218) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-04-30 23:40:57 UTC (rev 4219) @@ -10,568 +10,569 @@ namespace NHibernate.Hql.Ast.ANTLR.Tree { - public class FromElementFactory - { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); + [CLSCompliant(false)] + public class FromElementFactory + { + private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); - private readonly FromClause _fromClause; - private readonly FromElement _origin; - private readonly string _path; - private readonly bool _collection; - private readonly string _classAlias; - private readonly string[] _columns; - private bool _implied; - private bool _inElementsFunction; - private IQueryableCollection _queryableCollection; - private CollectionType _collectionType; + private readonly FromClause _fromClause; + private readonly FromElement _origin; + private readonly string _path; + private readonly bool _collection; + private readonly string _classAlias; + private readonly string[] _columns; + private bool _implied; + private bool _inElementsFunction; + private IQueryableCollection _queryableCollection; + private CollectionType _collectionType; - /// <summary> - /// Creates entity from elements. - /// </summary> - /// <param name="fromClause"></param> - /// <param name="origin"></param> - /// <param name="path"></param> - public FromElementFactory(FromClause fromClause, FromElement origin, string path) - { - _fromClause = fromClause; - _origin = origin; - _path = path; - _collection = false; - } + /// <summary> + /// Creates entity from elements. + /// </summary> + /// <param name="fromClause"></param> + /// <param name="origin"></param> + /// <param name="path"></param> + public FromElementFactory(FromClause fromClause, FromElement origin, string path) + { + _fromClause = fromClause; + _origin = origin; + _path = path; + _collection = false; + } - /// <summary> - /// Creates collection from elements. - /// </summary> - /// <param name="fromClause"></param> - /// <param name="origin"></param> - /// <param name="path"></param> - /// <param name="classAlias"></param> - /// <param name="columns"></param> - /// <param name="implied"></param> - public FromElementFactory( - FromClause fromClause, - FromElement origin, - string path, - string classAlias, - string[] columns, - bool implied) - : this(fromClause, origin, path) - { - _classAlias = classAlias; - _columns = columns; - _implied = implied; - _collection = true; - } + /// <summary> + /// Creates collection from elements. + /// </summary> + /// <param name="fromClause"></param> + /// <param name="origin"></param> + /// <param name="path"></param> + /// <param name="classAlias"></param> + /// <param name="columns"></param> + /// <param name="implied"></param> + public FromElementFactory( + FromClause fromClause, + FromElement origin, + string path, + string classAlias, + string[] columns, + bool implied) + : this(fromClause, origin, path) + { + _classAlias = classAlias; + _columns = columns; + _implied = implied; + _collection = true; + } - public FromElement AddFromElement() - { - FromClause parentFromClause = _fromClause.ParentFromClause; - if (parentFromClause != null) - { - // Look up class name using the first identifier in the path. - string pathAlias = PathHelper.GetAlias(_path); - FromElement parentFromElement = parentFromClause.GetFromElement(pathAlias); - if (parentFromElement != null) - { - return CreateFromElementInSubselect(_path, pathAlias, parentFromElement, _classAlias); - } - } + public FromElement AddFromElement() + { + FromClause parentFromClause = _fromClause.ParentFromClause; + if (parentFromClause != null) + { + // Look up class name using the first identifier in the path. + string pathAlias = PathHelper.GetAlias(_path); + FromElement parentFromElement = parentFromClause.GetFromElement(pathAlias); + if (parentFromElement != null) + { + return CreateFromElementInSubselect(_path, pathAlias, parentFromElement, _classAlias); + } + } - IEntityPersister entityPersister = _fromClause.SessionFactoryHelper.RequireClassPersister(_path); + IEntityPersister entityPersister = _fromClause.SessionFactoryHelper.RequireClassPersister(_path); - FromElement elem = CreateAndAddFromElement(_path, - _classAlias, - entityPersister, - (EntityType)((IQueryable)entityPersister).Type, - null); + FromElement elem = CreateAndAddFromElement(_path, + _classAlias, + entityPersister, + (EntityType)((IQueryable)entityPersister).Type, + null); - // Add to the query spaces. - _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); + // Add to the query spaces. + _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); - return elem; - } + return elem; + } - public FromElement CreateCollectionElementsJoin(IQueryableCollection queryableCollection, - String collectionName) - { - JoinSequence collectionJoinSequence = _fromClause.SessionFactoryHelper.CreateCollectionJoinSequence(queryableCollection, collectionName); - _queryableCollection = queryableCollection; - return CreateCollectionJoin(collectionJoinSequence, null); - } + public FromElement CreateCollectionElementsJoin(IQueryableCollection queryableCollection, + String collectionName) + { + JoinSequence collectionJoinSequence = _fromClause.SessionFactoryHelper.CreateCollectionJoinSequence(queryableCollection, collectionName); + _queryableCollection = queryableCollection; + return CreateCollectionJoin(collectionJoinSequence, null); + } - private FromElement CreateFromElementInSubselect( - string path, - string pathAlias, - FromElement parentFromElement, - string classAlias) - { - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : path = " + path); - } + private FromElement CreateFromElementInSubselect( + string path, + string pathAlias, + FromElement parentFromElement, + string classAlias) + { + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : path = " + path); + } - // Create an DotNode AST for the path and resolve it. - FromElement fromElement = EvaluateFromElementPath(path, classAlias); - IEntityPersister entityPersister = fromElement.EntityPersister; + // Create an DotNode AST for the path and resolve it. + FromElement fromElement = EvaluateFromElementPath(path, classAlias); + IEntityPersister entityPersister = fromElement.EntityPersister; - // If the first identifier in the path referrs to the class alias (not the class name), then this - // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. Otherwise - // generate a new one. - string tableAlias; - bool correlatedSubselect = pathAlias == parentFromElement.ClassAlias; - if (correlatedSubselect) - { - tableAlias = fromElement.TableAlias; - } - else - { - tableAlias = null; - } + // If the first identifier in the path referrs to the class alias (not the class name), then this + // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. Otherwise + // generate a new one. + string tableAlias; + bool correlatedSubselect = pathAlias == parentFromElement.ClassAlias; + if (correlatedSubselect) + { + tableAlias = fromElement.TableAlias; + } + else + { + tableAlias = null; + } - // If the from element isn't in the same clause, create a new from element. - if (fromElement.FromClause != _fromClause) - { - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : creating a new FROM element..."); - } + // If the from element isn't in the same clause, create a new from element. + if (fromElement.FromClause != _fromClause) + { + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : creating a new FROM element..."); + } - fromElement = CreateFromElement(entityPersister); + fromElement = CreateFromElement(entityPersister); - InitializeAndAddFromElement(fromElement, - path, - classAlias, - entityPersister, - (EntityType)((IQueryable)entityPersister).Type, - tableAlias - ); - } - if (log.IsDebugEnabled) - { - log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); - } + InitializeAndAddFromElement(fromElement, + path, + classAlias, + entityPersister, + (EntityType)((IQueryable)entityPersister).Type, + tableAlias + ); + } + if (log.IsDebugEnabled) + { + log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); + } - return fromElement; - } + return fromElement; + } - public FromElement CreateCollection(IQueryableCollection queryableCollection, - string role, - JoinType joinType, - bool fetchFlag, - bool indexed) - { - if (!_collection) - { - throw new InvalidOperationException("FromElementFactory not initialized for collections!"); - } + public FromElement CreateCollection(IQueryableCollection queryableCollection, + string role, + JoinType joinType, + bool fetchFlag, + bool indexed) + { + if (!_collection) + { + throw new InvalidOperationException("FromElementFactory not initialized for collections!"); + } - _inElementsFunction = indexed; - FromElement elem; - _queryableCollection = queryableCollection; - _collectionType = queryableCollection.CollectionType; - string roleAlias = _fromClause.AliasGenerator.CreateName(role); + _inElementsFunction = indexed; + FromElement elem; + _queryableCollection = queryableCollection; + _collectionType = queryableCollection.CollectionType; + string roleAlias = _fromClause.AliasGenerator.CreateName(role); - // Correlated subqueries create 'special' implied from nodes - // because correlated subselects can't use an ANSI-style join - bool explicitSubqueryFromElement = _fromClause.IsSubQuery && !_implied; - if (explicitSubqueryFromElement) - { - string pathRoot = StringHelper.Root(_path); - FromElement origin = _fromClause.GetFromElement(pathRoot); - if (origin == null || origin.FromClause != _fromClause) - { - _implied = true; - } - } + // Correlated subqueries create 'special' implied from nodes + // because correlated subselects can't use an ANSI-style join + bool explicitSubqueryFromElement = _fromClause.IsSubQuery && !_implied; + if (explicitSubqueryFromElement) + { + string pathRoot = StringHelper.Root(_path); + FromElement origin = _fromClause.GetFromElement(pathRoot); + if (origin == null || origin.FromClause != _fromClause) + { + _implied = true; + } + } - // super-duper-classic-parser-regression-testing-mojo-magic... - if (explicitSubqueryFromElement && DotNode.UseThetaStyleImplicitJoins) - { - _implied = true; - } + // super-duper-classic-parser-regression-testing-mojo-magic... + if (explicitSubqueryFromElement && DotNode.UseThetaStyleImplicitJoins) + { + _implied = true; + } - IType elementType = queryableCollection.ElementType; + IType elementType = queryableCollection.ElementType; - if (elementType.IsEntityType) - { - // A collection of entities... - elem = CreateEntityAssociation(role, roleAlias, joinType); - } - else if (elementType.IsComponentType) - { - // A collection of components... - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateCollectionJoin(joinSequence, roleAlias); - } - else - { - // A collection of scalar elements... - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateCollectionJoin(joinSequence, roleAlias); - } + if (elementType.IsEntityType) + { + // A collection of entities... + elem = CreateEntityAssociation(role, roleAlias, joinType); + } + else if (elementType.IsComponentType) + { + // A collection of components... + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + elem = CreateCollectionJoin(joinSequence, roleAlias); + } + else + { + // A collection of scalar elements... + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + elem = CreateCollectionJoin(joinSequence, roleAlias); + } - elem.SetRole(role); - elem.QueryableCollection = queryableCollection; - // Don't include sub-classes for implied collection joins or subquery joins. - if (_implied) - { - elem.IncludeSubclasses = false; - } + elem.SetRole(role); + elem.QueryableCollection = queryableCollection; + // Don't include sub-classes for implied collection joins or subquery joins. + if (_implied) + { + elem.IncludeSubclasses = false; + } - if (explicitSubqueryFromElement) - { - elem.InProjectionList = true; // Treat explict from elements in sub-queries properly. - } + if (explicitSubqueryFromElement) + { + elem.InProjectionList = true; // Treat explict from elements in sub-queries properly. + } - if (fetchFlag) - { - elem.Fetch = true; - } - return elem; - } + if (fetchFlag) + { + elem.Fetch = true; + } + return elem; + } - public FromElement CreateElementJoin(IQueryableCollection queryableCollection) - { - FromElement elem; + public FromElement CreateElementJoin(IQueryableCollection queryableCollection) + { + FromElement elem; - _implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause - _inElementsFunction = true; + _implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause + _inElementsFunction = true; - IType elementType = queryableCollection.ElementType; + IType elementType = queryableCollection.ElementType; - if (!elementType.IsEntityType) - { - throw new InvalidOperationException("Cannot create element join for a collection of non-entities!"); - } + if (!elementType.IsEntityType) + { + throw new InvalidOperationException("Cannot create element join for a collection of non-entities!"); + } - _queryableCollection = queryableCollection; + _queryableCollection = queryableCollection; - SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; - FromElement destination = null; - string tableAlias = null; - IEntityPersister entityPersister = queryableCollection.ElementPersister; - tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); - string associatedEntityName = entityPersister.EntityName; - IEntityPersister targetEntityPersister = sfh.RequireClassPersister(associatedEntityName); + SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; + FromElement destination = null; + string tableAlias = null; + IEntityPersister entityPersister = queryableCollection.ElementPersister; + tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); + string associatedEntityName = entityPersister.EntityName; + IEntityPersister targetEntityPersister = sfh.RequireClassPersister(associatedEntityName); - // Create the FROM element for the target (the elements of the collection). - destination = CreateAndAddFromElement( - associatedEntityName, - _classAlias, - targetEntityPersister, - (EntityType)queryableCollection.ElementType, - tableAlias - ); + // Create the FROM element for the target (the elements of the collection). + destination = CreateAndAddFromElement( + associatedEntityName, + _classAlias, + targetEntityPersister, + (EntityType)queryableCollection.ElementType, + tableAlias + ); - // If the join is implied, then don't include sub-classes on the element. - if (_implied) - { - destination.IncludeSubclasses = false; - } + // If the join is implied, then don't include sub-classes on the element. + if (_implied) + { + destination.IncludeSubclasses = false; + } - _fromClause.AddCollectionJoinFromElementByPath(_path, destination); - // origin.addDestination(destination); - // Add the query spaces. - _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); + _fromClause.AddCollectionJoinFromElementByPath(_path, destination); + // origin.addDestination(destination); + // Add the query spaces. + _fromClause.Walker.AddQuerySpaces(entityPersister.QuerySpaces); - CollectionType type = queryableCollection.CollectionType; - string role = type.Role; - string roleAlias = _origin.TableAlias; + CollectionType type = queryableCollection.CollectionType; + string role = type.Role; + string roleAlias = _origin.TableAlias; - string[] targetColumns = sfh.GetCollectionElementColumns(role, roleAlias); - IAssociationType elementAssociationType = sfh.GetElementAssociationType(type); + string[] targetColumns = sfh.GetCollectionElementColumns(role, roleAlias); + IAssociationType elementAssociationType = sfh.GetElementAssociationType(type); - // Create the join element under the from element. - JoinType joinType = JoinType.InnerJoin; - JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, joinType, targetColumns); - elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); - elem.UseFromFragment = true; // The associated entity is implied, but it must be included in the FROM. - elem.CollectionTableAlias = roleAlias; // The collection alias is the role. - return elem; - } + // Create the join element under the from element. + JoinType joinType = JoinType.InnerJoin; + JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, joinType, targetColumns); + elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); + elem.UseFromFragment = true; // The associated entity is implied, but it must be included in the FROM. + elem.CollectionTableAlias = roleAlias; // The collection alias is the role. + return elem; + } - public FromElement CreateEntityJoin( - string entityClass, - string tableAlias, - JoinSequence joinSequence, - bool fetchFlag, - bool inFrom, - EntityType type) - { - FromElement elem = CreateJoin(entityClass, tableAlias, joinSequence, type, false); - elem.Fetch = fetchFlag; - IEntityPersister entityPersister = elem.EntityPersister; - int numberOfTables = entityPersister.QuerySpaces.Length; + public FromElement CreateEntityJoin( + string entityClass, + string tableAlias, + JoinSequence joinSequence, + bool fetchFlag, + bool inFrom, + EntityType type) + { + FromElement elem = CreateJoin(entityClass, tableAlias, joinSequence, type, false); + elem.Fetch = fetchFlag; + IEntityPersister entityPersister = elem.EntityPersister; + int numberOfTables = entityPersister.QuerySpaces.Length; - if (numberOfTables > 1 && _implied && !elem.UseFromFragment) - { - if (log.IsDebugEnabled) - { - log.Debug("createEntityJoin() : Implied multi-table entity join"); - } - elem.UseFromFragment = true; - } + if (numberOfTables > 1 && _implied && !elem.UseFromFragment) + { + if (log.IsDebugEnabled) + { + log.Debug("createEntityJoin() : Implied multi-table entity join"); + } + elem.UseFromFragment = true; + } - // If this is an implied join in a FROM clause, then use ANSI-style joining, and set the - // flag on the FromElement that indicates that it was implied in the FROM clause itself. - if (_implied && inFrom) - { - joinSequence.SetUseThetaStyle(false); - elem.UseFromFragment = true; - elem.SetImpliedInFromClause(true); - } - if (elem.Walker.IsSubQuery) - { - // two conditions where we need to transform this to a theta-join syntax: - // 1) 'elem' is the "root from-element" in correlated subqueries - // 2) The DotNode.useThetaStyleImplicitJoins has been set to true - // and 'elem' represents an implicit join - if (elem.FromClause != elem.Origin.FromClause || - // ( implied && DotNode.useThetaStyleImplicitJoins ) ) { - DotNode.UseThetaStyleImplicitJoins) - { - // the "root from-element" in correlated subqueries do need this piece - elem.Type = HqlSqlWalker.FROM_FRAGMENT; - joinSequence.SetUseThetaStyle(true); - elem.UseFromFragment = false; - } - } + // If this is an implied join in a FROM clause, then use ANSI-style joining, and set the + // flag on the FromElement that indicates that it was implied in the FROM clause itself. + if (_implied && inFrom) + { + joinSequence.SetUseThetaStyle(false); + elem.UseFromFragment = true; + elem.SetImpliedInFromClause(true); + } + if (elem.Walker.IsSubQuery) + { + // two conditions where we need to transform this to a theta-join syntax: + // 1) 'elem' is the "root from-element" in correlated subqueries + // 2) The DotNode.useThetaStyleImplicitJoins has been set to true + // and 'elem' represents an implicit join + if (elem.FromClause != elem.Origin.FromClause || + // ( implied && DotNode.useThetaStyleImplicitJoins ) ) { + DotNode.UseThetaStyleImplicitJoins) + { + // the "root from-element" in correlated subqueries do need this piece + elem.Type = HqlSqlWalker.FROM_FRAGMENT; + joinSequence.SetUseThetaStyle(true); + elem.UseFromFragment = false; + } + } - return elem; - } + return elem; + } - private FromElement CreateEntityAssociation( - string role, - string roleAlias, - JoinType joinType) - { - FromElement elem; - IQueryable entityPersister = (IQueryable)_queryableCollection.ElementPersister; - string associatedEntityName = entityPersister.EntityName; + private FromElement CreateEntityAssociation( + string role, + string roleAlias, + JoinType joinType) + { + FromElement elem; + IQueryable entityPersister = (IQueryable)_queryableCollection.ElementPersister; + string associatedEntityName = entityPersister.EntityName; - // Get the class name of the associated entity. - if (_queryableCollection.IsOneToMany) - { - if (log.IsDebugEnabled) - { - log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); - } + // Get the class name of the associated entity. + if (_queryableCollection.IsOneToMany) + { + if (log.IsDebugEnabled) + { + log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + } - JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); + JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); - elem = CreateJoin(associatedEntityName, roleAlias, joinSequence, (EntityType)_queryableCollection.ElementType, false); - } - else - { - if (log.IsDebugEnabled) - { - log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); - } + elem = CreateJoin(associatedEntityName, roleAlias, joinSequence, (EntityType)_queryableCollection.ElementType, false); + } + else + { + if (log.IsDebugEnabled) + { + log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + } - elem = CreateManyToMany(role, associatedEntityName, - roleAlias, entityPersister, (EntityType)_queryableCollection.ElementType, joinType); - _fromClause.Walker.AddQuerySpaces(_queryableCollection.CollectionSpaces); - } - elem.CollectionTableAlias = roleAlias; - return elem; - } + elem = CreateManyToMany(role, associatedEntityName, + roleAlias, entityPersister, (EntityType)_queryableCollection.ElementType, joinType); + _fromClause.Walker.AddQuerySpaces(_queryableCollection.CollectionSpaces); + } + elem.CollectionTableAlias = roleAlias; + return elem; + } - private FromElement CreateCollectionJoin(JoinSequence collectionJoinSequence, string tableAlias) - { - string text = _queryableCollection.TableName; - IASTNode ast = CreateFromElement(text); - FromElement destination = (FromElement)ast; - IType elementType = _queryableCollection.ElementType; + private FromElement CreateCollectionJoin(JoinSequence collectionJoinSequence, string tableAlias) + { + string text = _queryableCollection.TableName; + IASTNode ast = CreateFromElement(text); + FromElement destination = (FromElement)ast; + IType elementType = _queryableCollection.ElementType; - if (elementType.IsCollectionType) - { - throw new SemanticException("Collections of collections are not supported!"); - } + if (elementType.IsCollectionType) + { + throw new SemanticException("Collections of collections are not supported!"); + } - destination.InitializeCollection(_fromClause, _classAlia... [truncated message content] |
From: <fab...@us...> - 2009-05-01 14:09:07
|
Revision: 4221 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4221&view=rev Author: fabiomaulo Date: 2009-05-01 14:09:04 +0000 (Fri, 01 May 2009) Log Message: ----------- renamed file Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-04-30 23:44:59 UTC (rev 4220) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-05-01 14:09:04 UTC (rev 4221) @@ -1,21 +0,0 @@ -namespace NHibernate.Hql.Ast.ANTLR.Parameters -{ - /// <summary> - /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement - /// (HQL or native-SQL). - /// Author: Steve Ebersole - /// Ported by: Steve Strong - /// </summary> - public interface IExplicitParameterSpecification : IParameterSpecification - { - /// <summary> - /// Retrieves the line number on which this parameter occurs in the source query. - /// </summary> - int SourceLine { get; } - - /// <summary> - /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. - /// </summary> - int SourceColumn { get; } - } -} Copied: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs (from rev 4219, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs 2009-05-01 14:09:04 UTC (rev 4221) @@ -0,0 +1,21 @@ +namespace NHibernate.Hql.Ast.ANTLR.Parameters +{ + /// <summary> + /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement + /// (HQL or native-SQL). + /// Author: Steve Ebersole + /// Ported by: Steve Strong + /// </summary> + public interface IExplicitParameterSpecification : IParameterSpecification + { + /// <summary> + /// Retrieves the line number on which this parameter occurs in the source query. + /// </summary> + int SourceLine { get; } + + /// <summary> + /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. + /// </summary> + int SourceColumn { get; } + } +} Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-04-30 23:44:59 UTC (rev 4220) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:09:04 UTC (rev 4221) @@ -500,7 +500,7 @@ <Compile Include="Hql\Ast\ANTLR\Parameters\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\CollectionFilterKeyParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\DynamicFilterParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\ExplicitParameterSpecification.cs" /> + <Compile Include="Hql\Ast\ANTLR\Parameters\IExplicitParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\IParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\NamedParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Parameters\ParameterTranslationsImpl.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-01 14:55:38
|
Revision: 4222 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4222&view=rev Author: fabiomaulo Date: 2009-05-01 14:55:28 +0000 (Fri, 01 May 2009) Log Message: ----------- Refactoring: - Moved Parameters classes to NH namespace (as in Hb) - Removed TODO.cs (the last method was moved in StringHelper) - Moved NullableDictionary to default util (it need some investigation about its real usage) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs trunk/nhibernate/src/NHibernate/Util/StringHelper.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Param/ trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -6,7 +6,7 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,16 +1,17 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime.Tree; using Iesi.Collections.Generic; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; +using NHibernate.Util; namespace NHibernate.Hql.Ast.ANTLR { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,14 +1,13 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; -using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Impl; using NHibernate.Loader; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -8,9 +8,9 @@ using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Exec; using NHibernate.Hql.Ast.ANTLR.Loader; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,9 +1,8 @@ -using System; +using System; using System.Collections.Generic; using NHibernate.Dialect.Function; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Tree; -using NHibernate.Hql.Ast.ANTLR.Util; using NHibernate.Hql.Util; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,12 +1,12 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using Antlr.Runtime; using Antlr.Runtime.Tree; using NHibernate.Dialect.Function; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; using NHibernate.SqlCommand; namespace NHibernate.Hql.Ast.ANTLR Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/TODO.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,19 +0,0 @@ -using System; - -namespace NHibernate.Hql.Ast.ANTLR -{ - public class LoadQueryInfluencers - { - public static string[] ParseFilterParameterName(string filterParameterName) - { - int dot = filterParameterName.IndexOf("."); - if (dot <= 0) - { - throw new ArgumentException("Invalid filter-parameter name format", "filterParameterName"); - } - string filterName = filterParameterName.Substring(0, dot); - string parameterName = filterParameterName.Substring(dot + 1); - return new[] { filterName, parameterName }; - } - } -} Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,7 +1,7 @@ -using System; +using System; using Antlr.Runtime; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Type; using NHibernate.Util; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; using Iesi.Collections.Generic; using log4net; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Util; namespace NHibernate.Hql.Ast.ANTLR.Tree { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using Antlr.Runtime; using log4net; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -3,7 +3,7 @@ using System.Text; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IParameterContainer.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,4 +1,4 @@ -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; namespace NHibernate.Hql.Ast.ANTLR.Tree { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; using Antlr.Runtime.Tree; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,8 +1,8 @@ -using System; +using System; using System.Text; using Antlr.Runtime; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.Type; namespace NHibernate.Hql.Ast.ANTLR.Tree Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,7 +1,7 @@ -using System; +using System; using System.Collections.Generic; using Antlr.Runtime; -using NHibernate.Hql.Ast.ANTLR.Parameters; +using NHibernate.Param; using NHibernate.SqlCommand; namespace NHibernate.Hql.Ast.ANTLR.Tree Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/JoinProcessor.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,13 +1,13 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Text; using log4net; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Classic; using NHibernate.Impl; +using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; @@ -180,7 +180,7 @@ if ( token.StartsWith( ParserHelper.HqlVariablePrefix ) ) { string filterParameterName = token.Substring( 1 ); - string[] parts = LoadQueryInfluencers.ParseFilterParameterName( filterParameterName ); + string[] parts = StringHelper.ParseFilterParameterName( filterParameterName ); FilterImpl filter = ( FilterImpl ) walker.EnabledFilters[parts[0]]; Object value = filter.GetParameter( parts[1] ); IType type = filter.FilterDefinition.GetParameterType( parts[1] ); Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,230 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace NHibernate.Hql.Ast.ANTLR.Util -{ - public class NullableDictionary<TKey, TValue> : IDictionary<TKey, TValue> - where TKey : class - { - private TValue _nullValue; - private bool _gotNullValue; - private readonly Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); - - public bool ContainsKey(TKey key) - { - if (key == null) - { - return _gotNullValue; - } - else - { - return _dict.ContainsKey(key); - } - } - - public void Add(TKey key, TValue value) - { - if (key == null) - { - _nullValue = value; - } - else - { - _dict[key] = value; - } - } - - public bool Remove(TKey key) - { - if (key == null) - { - if (_gotNullValue) - { - _nullValue = default(TValue); - _gotNullValue = false; - return true; - } - else - { - return false; - } - } - else - { - return _dict.Remove(key); - } - } - - public bool TryGetValue(TKey key, out TValue value) - { - if (key == null) - { - if (_gotNullValue) - { - value = _nullValue; - return true; - } - else - { - value = default(TValue); - return false; - } - } - else - { - return _dict.TryGetValue(key, out value); - } - } - - public TValue this[TKey key] - { - get - { - if (key == null) - { - return _nullValue; - } - else - { - TValue ret; - - _dict.TryGetValue(key, out ret); - - return ret; - } - } - set - { - if (key == null) - { - _nullValue = value; - _gotNullValue = true; - } - else - { - _dict[key] = value; - } - } - } - - public ICollection<TKey> Keys - { - get - { - if (_gotNullValue) - { - List<TKey> keys = new List<TKey>(_dict.Keys); - keys.Add(null); - return keys; - } - else - { - return _dict.Keys; - } - } - } - - public ICollection<TValue> Values - { - get - { - if (_gotNullValue) - { - List<TValue> values = new List<TValue>(_dict.Values); - values.Add(_nullValue); - return values; - } - else - { - return _dict.Values; - } - } - } - - public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() - { - foreach (KeyValuePair<TKey, TValue> kvp in _dict) - { - yield return kvp; - } - - if (_gotNullValue) - { - yield return new KeyValuePair<TKey, TValue>(null, _nullValue); - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void Add(KeyValuePair<TKey, TValue> item) - { - if (item.Key == null) - { - _nullValue = item.Value; - _gotNullValue = true; - } - else - { - _dict.Add(item.Key, item.Value); - } - } - - public void Clear() - { - _dict.Clear(); - _nullValue = default(TValue); - _gotNullValue = false; - } - - public bool Contains(KeyValuePair<TKey, TValue> item) - { - TValue val = default(TValue); - - if (TryGetValue(item.Key, out val)) - { - if (Equals(item.Value, val)) - { - return true; - } - return false; - } - else - { - return false; - } - } - - public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) - { - throw new System.NotImplementedException(); - } - - public bool Remove(KeyValuePair<TKey, TValue> item) - { - throw new System.NotImplementedException(); - } - - public int Count - { - get - { - if (_gotNullValue) - { - return _dict.Count + 1; - } - else - { - return _dict.Count; - } - } - } - - public bool IsReadOnly - { - get { return false; } - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,8 +1,8 @@ -using System; +using System; using Antlr.Runtime.Tree; using log4net; -using NHibernate.Hql.Ast.ANTLR.Parameters; using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-01 14:55:28 UTC (rev 4222) @@ -496,21 +496,20 @@ <Compile Include="Hql\Ast\ANTLR\InvalidWithClauseException.cs" /> <Compile Include="Hql\Ast\ANTLR\IParseErrorHandler.cs" /> <Compile Include="Hql\Ast\ANTLR\Loader\QueryLoader.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\AbstractExplicitParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\CollectionFilterKeyParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\DynamicFilterParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\IExplicitParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\IParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\NamedParameterSpecification.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\ParameterTranslationsImpl.cs" /> - <Compile Include="Hql\Ast\ANTLR\Parameters\PositionalParameterSpecification.cs" /> + <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> + <Compile Include="Param\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> + <Compile Include="Param\CollectionFilterKeyParameterSpecification.cs" /> + <Compile Include="Param\DynamicFilterParameterSpecification.cs" /> + <Compile Include="Param\IExplicitParameterSpecification.cs" /> + <Compile Include="Param\IParameterSpecification.cs" /> + <Compile Include="Param\NamedParameterSpecification.cs" /> + <Compile Include="Param\ParameterTranslationsImpl.cs" /> + <Compile Include="Param\PositionalParameterSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\QuerySyntaxException.cs" /> <Compile Include="Hql\Ast\ANTLR\QueryTranslatorImpl.cs" /> <Compile Include="Hql\Ast\ANTLR\SemanticException.cs" /> <Compile Include="Hql\Ast\ANTLR\SessionFactoryHelperExtensions.cs" /> <Compile Include="Hql\Ast\ANTLR\SqlGenerator.cs" /> - <Compile Include="Hql\Ast\ANTLR\TODO.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractNullnessCheckNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractRestrictableStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\AbstractSelectExpression.cs" /> @@ -585,7 +584,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\JoinProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> - <Compile Include="Hql\Ast\ANTLR\Util\NullableDictionary.cs" /> + <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> <Compile Include="Id\TriggerIdentityGenerator.cs" /> Modified: trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/AbstractExplicitParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/AbstractExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,13 +2,8 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { - /** - * Convenience base class for explicitly defined query parameters. - * - * @author Steve Ebersole - */ public abstract class AbstractExplicitParameterSpecification : IExplicitParameterSpecification { private readonly int _sourceLine; @@ -44,4 +39,4 @@ public abstract string RenderDisplayInfo(); public abstract int Bind(IDbCommand statement, QueryParameters qp, ISessionImplementor session, int position); } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/AggregatedIndexCollectionSelectorParameterSpecifications.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/AggregatedIndexCollectionSelectorParameterSpecifications.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -4,7 +4,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { public class AggregatedIndexCollectionSelectorParameterSpecifications : IParameterSpecification { @@ -49,4 +49,4 @@ return buffer.ToString(); } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/CollectionFilterKeyParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/CollectionFilterKeyParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -3,7 +3,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { class CollectionFilterKeyParameterSpecification : IParameterSpecification { @@ -25,10 +25,10 @@ } public int Bind( - IDbCommand statement, - QueryParameters qp, - ISessionImplementor session, - int position) + IDbCommand statement, + QueryParameters qp, + ISessionImplementor session, + int position) { object value = qp.PositionalParameterValues[_queryParameterPosition]; _keyType.NullSafeSet(statement, value, position, session); @@ -46,4 +46,4 @@ return "collection-filter-key=" + _collectionRole; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/DynamicFilterParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/DynamicFilterParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -4,7 +4,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { public class DynamicFilterParameterSpecification : IParameterSpecification { @@ -19,9 +19,9 @@ /// <param name="parameterName">The name of the parameter</param> /// <param name="definedParameterType">The paremeter type specified on the filter metadata</param> public DynamicFilterParameterSpecification( - string filterName, - string parameterName, - IType definedParameterType) + string filterName, + string parameterName, + IType definedParameterType) { _filterName = filterName; _parameterName = parameterName; @@ -64,4 +64,4 @@ return "dynamic-filter={filterName=" + _filterName + ",paramName=" + _parameterName + "}"; } } -} +} \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ExplicitParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/ExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,21 +0,0 @@ -namespace NHibernate.Hql.Ast.ANTLR.Parameters -{ - /// <summary> - /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement - /// (HQL or native-SQL). - /// Author: Steve Ebersole - /// Ported by: Steve Strong - /// </summary> - public interface IExplicitParameterSpecification : IParameterSpecification - { - /// <summary> - /// Retrieves the line number on which this parameter occurs in the source query. - /// </summary> - int SourceLine { get; } - - /// <summary> - /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. - /// </summary> - int SourceColumn { get; } - } -} Copied: trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs (from rev 4221, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IExplicitParameterSpecification.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Param/IExplicitParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -0,0 +1,21 @@ +namespace NHibernate.Param +{ + /// <summary> + /// An additional contract for parameters which originate from parameters explicitly encountered in the source statement + /// (HQL or native-SQL). + /// Author: Steve Ebersole + /// Ported by: Steve Strong + /// </summary> + public interface IExplicitParameterSpecification : IParameterSpecification + { + /// <summary> + /// Retrieves the line number on which this parameter occurs in the source query. + /// </summary> + int SourceLine { get; } + + /// <summary> + /// Retrieves the column number (within the {@link #getSourceLine()}) where this parameter occurs. + /// </summary> + int SourceColumn { get; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/IParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/IParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using NHibernate.Engine; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Maintains information relating to parameters which need to get bound into a @@ -34,4 +34,4 @@ /// <returns>The displayable info</returns> string RenderDisplayInfo(); } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/NamedParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using System.Data; using NHibernate.Engine; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Parameter bind specification for an explicit named parameter. @@ -51,5 +51,4 @@ get { return _name; } } } - -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/ParameterTranslationsImpl.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using NHibernate.Engine; -using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Hql; using NHibernate.Type; using NHibernate.Util; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Defines the information available for parameters encountered during @@ -46,13 +46,13 @@ else { // don't care about other param types here, just those explicitly user-defined... - // Steve Strong Note: The original Java does not do this decrement; it increments i for - // every parameter type. However, within the Loader.GetParameterTypes() method, this introduces - // nulls into the paramTypeList array, which in turn causes Loader.ConvertITypesToSqlTypes() to crash - // with a null dereference. An alternative fix is to change the Loader to handle the null. I'm - // not sure which fix is the most appropriate. - // Legacy.FumTest.CompositeIDQuery() shows the bug if you remove the decrement below... - i--; + // Steve Strong Note: The original Java does not do this decrement; it increments i for + // every parameter type. However, within the Loader.GetParameterTypes() method, this introduces + // nulls into the paramTypeList array, which in turn causes Loader.ConvertITypesToSqlTypes() to crash + // with a null dereference. An alternative fix is to change the Loader to handle the null. I'm + // not sure which fix is the most appropriate. + // Legacy.FumTest.CompositeIDQuery() shows the bug if you remove the decrement below... + i--; } i++; @@ -67,22 +67,22 @@ } } - public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) - { - foreach (ParameterInfo entry in _namedParameters.Values) - { - for (int index = 0; index < entry.SqlLocations.Length; index++) - { - if (entry.SqlLocations[index] >= existingParameterLocation) - { - entry.SqlLocations[index]++; - } - } - } - } - } + public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) + { + foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + { + foreach (ParameterInfo entry in _namedParameters.Values) + { + for (int index = 0; index < entry.SqlLocations.Length; index++) + { + if (entry.SqlLocations[index] >= existingParameterLocation) + { + entry.SqlLocations[index]++; + } + } + } + } + } public int GetOrdinalParameterSqlLocation(int ordinalPosition) { @@ -164,4 +164,4 @@ get { return _expectedType; } } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Parameters/PositionalParameterSpecification.cs 2009-04-30 23:40:57 UTC (rev 4219) +++ trunk/nhibernate/src/NHibernate/Param/PositionalParameterSpecification.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -2,7 +2,7 @@ using System.Data; using NHibernate.Type; -namespace NHibernate.Hql.Ast.ANTLR.Parameters +namespace NHibernate.Param { /// <summary> /// Parameter bind specification for an explicit positional (or ordinal) parameter. @@ -54,4 +54,4 @@ get { return _hqlPosition; } } } -} +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs (from rev 4219, trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/NullableDictionary.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Util/NullableDictionary.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -0,0 +1,230 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NHibernate.Util +{ + public class NullableDictionary<TKey, TValue> : IDictionary<TKey, TValue> + where TKey : class + { + private TValue _nullValue; + private bool _gotNullValue; + private readonly Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); + + public bool ContainsKey(TKey key) + { + if (key == null) + { + return _gotNullValue; + } + else + { + return _dict.ContainsKey(key); + } + } + + public void Add(TKey key, TValue value) + { + if (key == null) + { + _nullValue = value; + } + else + { + _dict[key] = value; + } + } + + public bool Remove(TKey key) + { + if (key == null) + { + if (_gotNullValue) + { + _nullValue = default(TValue); + _gotNullValue = false; + return true; + } + else + { + return false; + } + } + else + { + return _dict.Remove(key); + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (key == null) + { + if (_gotNullValue) + { + value = _nullValue; + return true; + } + else + { + value = default(TValue); + return false; + } + } + else + { + return _dict.TryGetValue(key, out value); + } + } + + public TValue this[TKey key] + { + get + { + if (key == null) + { + return _nullValue; + } + else + { + TValue ret; + + _dict.TryGetValue(key, out ret); + + return ret; + } + } + set + { + if (key == null) + { + _nullValue = value; + _gotNullValue = true; + } + else + { + _dict[key] = value; + } + } + } + + public ICollection<TKey> Keys + { + get + { + if (_gotNullValue) + { + List<TKey> keys = new List<TKey>(_dict.Keys); + keys.Add(null); + return keys; + } + else + { + return _dict.Keys; + } + } + } + + public ICollection<TValue> Values + { + get + { + if (_gotNullValue) + { + List<TValue> values = new List<TValue>(_dict.Values); + values.Add(_nullValue); + return values; + } + else + { + return _dict.Values; + } + } + } + + public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() + { + foreach (KeyValuePair<TKey, TValue> kvp in _dict) + { + yield return kvp; + } + + if (_gotNullValue) + { + yield return new KeyValuePair<TKey, TValue>(null, _nullValue); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair<TKey, TValue> item) + { + if (item.Key == null) + { + _nullValue = item.Value; + _gotNullValue = true; + } + else + { + _dict.Add(item.Key, item.Value); + } + } + + public void Clear() + { + _dict.Clear(); + _nullValue = default(TValue); + _gotNullValue = false; + } + + public bool Contains(KeyValuePair<TKey, TValue> item) + { + TValue val = default(TValue); + + if (TryGetValue(item.Key, out val)) + { + if (Equals(item.Value, val)) + { + return true; + } + return false; + } + else + { + return false; + } + } + + public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) + { + throw new System.NotImplementedException(); + } + + public bool Remove(KeyValuePair<TKey, TValue> item) + { + throw new System.NotImplementedException(); + } + + public int Count + { + get + { + if (_gotNullValue) + { + return _dict.Count + 1; + } + else + { + return _dict.Count; + } + } + } + + public bool IsReadOnly + { + get { return false; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Util/StringHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-05-01 14:09:04 UTC (rev 4221) +++ trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-05-01 14:55:28 UTC (rev 4222) @@ -722,5 +722,17 @@ } return identifier; } + + public static string[] ParseFilterParameterName(string filterParameterName) + { + int dot = filterParameterName.IndexOf("."); + if (dot <= 0) + { + throw new ArgumentException("Invalid filter-parameter name format; the name should be a property path.", "filterParameterName"); + } + string filterName = filterParameterName.Substring(0, dot); + string parameterName = filterParameterName.Substring(dot + 1); + return new[] { filterName, parameterName }; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-02 05:10:05
|
Revision: 4223 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4223&view=rev Author: fabiomaulo Date: 2009-05-02 05:10:00 +0000 (Sat, 02 May 2009) Log Message: ----------- First test for executable HQL passed Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -6,9 +6,11 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Param; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; +using NHibernate.SqlTypes; namespace NHibernate.Hql.Ast.ANTLR.Exec { @@ -17,18 +19,19 @@ { private readonly IQueryable persister; private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); - private SqlString sql; + private readonly SqlString sql; - public BasicExecutor(HqlSqlWalker walker, IQueryable persister) : base(walker, log) + public BasicExecutor(IStatement statement, ITokenStream tokenStream, IQueryable persister) + : base(statement.Walker, log) { this.persister = persister; try { + var generator = new HqlSqlGenerator(statement, tokenStream, Factory); + generator.Generate(); - //SqlGenerator gen = new SqlGenerator(Factory); - //gen.statement(walker.getAST()); - //sql = gen.GetSQL(); - //gen.ParseErrorHandler.ThrowQueryException(); + sql = generator.Sql; + Parameters = generator.CollectionParameters; } catch (RecognitionException e) { @@ -36,6 +39,8 @@ } } + protected IList<IParameterSpecification> Parameters{get;private set;} + protected ISessionFactoryImplementor Factory { get @@ -60,8 +65,13 @@ { try { - //st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes); - IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + var parameterTypes = new List<SqlType>(Parameters.Count); + foreach (var parameterSpecification in Parameters) + { + parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); + } + st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); + IEnumerator<IParameterSpecification> paramSpecifications = Parameters.GetEnumerator(); int pos = 1; while (paramSpecifications.MoveNext()) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -165,7 +165,7 @@ void PostProcessDelete(IASTNode delete) { - throw new NotImplementedException(); // DML + PostProcessDML((DeleteStatement)delete); } void PostProcessInsert(IASTNode insert) @@ -173,6 +173,24 @@ throw new NotImplementedException(); // DML } + private void PostProcessDML(IRestrictableStatement statement) + { + statement.FromClause.Resolve(); + + var fromElement = (FromElement)statement.FromClause.GetFromElements()[0]; + IQueryable persister = fromElement.Queryable; + // Make #@%$^#^&# sure no alias is applied to the table name + fromElement.Text = persister.TableName; + + // append any filter fragments; the EMPTY_MAP is used under the assumption that + // currently enabled filters should not affect this process + if (persister.DiscriminatorType != null) + { + new SyntheticAndFactory(this) + .AddDiscriminatorWhereFragment(statement, persister, new CollectionHelper.EmptyMapClass<string, IFilter>(), fromElement.TableAlias); + } + } + void AfterStatementCompletion(string statementName) { if (log.IsDebugEnabled) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -166,9 +166,18 @@ public int ExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session) { - throw new System.NotImplementedException(); // DML + ErrorIfSelect(); + return statementExecutor.Execute(queryParameters, session); } + private void ErrorIfSelect() + { + if (!sqlAst.NeedsExecutor) + { + throw new QueryExecutionRequestException("Not supported for select queries:", _hql); + } + } + public NHibernate.Loader.Loader Loader { get { return _queryLoader; } @@ -229,17 +238,14 @@ { get { - List<string> list = new List<string>(); + var list = new List<string>(); if (IsManipulationStatement) { - throw new NotImplementedException(); // DML - /* - String[] sqlStatements = statementExecutor.getSqlStatements(); - for (int i = 0; i < sqlStatements.length; i++) + SqlString[] sqlStatements = statementExecutor.SqlStatements; + foreach (var sqlStatement in sqlStatements) { - list.Add(sqlStatements[i]); + list.Add(sqlStatement.ToString()); } - */ } else { @@ -340,7 +346,7 @@ // PHASE 2 : Analyze the HQL AST, and produce an SQL AST. HqlSqlWalker w = Analyze(parser, collectionRole); - sqlAst = (IStatement)w.statement().Tree; + sqlAst = _translator.SqlStatement; // at some point the generate phase needs to be moved out of here, // because a single object-level DML might spawn multiple SQL DML @@ -353,14 +359,14 @@ // QueryLoader currently even has a dependency on this at all; does // it need it? Ideally like to see the walker itself given to the delegates directly... - if (_translator.SqlStatement.NeedsExecutor) + if (sqlAst.NeedsExecutor) { - statementExecutor = BuildAppropriateStatementExecutor(w); + statementExecutor = BuildAppropriateStatementExecutor(sqlAst); } else { // PHASE 3 : Generate the SQL. - _generator = new HqlSqlGenerator(_translator.SqlStatement, parser.Tokens, _factory); + _generator = new HqlSqlGenerator(sqlAst, parser.Tokens, _factory); _generator.Generate(); _queryLoader = new QueryLoader(this, _factory, w.SelectClause); @@ -387,8 +393,9 @@ _enabledFilters = null; //only needed during compilation phase... } - private IStatementExecutor BuildAppropriateStatementExecutor(HqlSqlWalker walker) + private IStatementExecutor BuildAppropriateStatementExecutor(IStatement statement) { + HqlSqlWalker walker = statement.Walker; if (walker.StatementType == HqlSqlWalker.DELETE) { FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); @@ -400,7 +407,7 @@ } else { - return new BasicExecutor(walker, persister); + return new BasicExecutor(statement, _parser.Tokens, persister); } } else if (walker.StatementType == HqlSqlWalker.UPDATE) @@ -417,7 +424,7 @@ } else { - return new BasicExecutor(walker, persister); + return new BasicExecutor(statement, _parser.Tokens, persister); } } else if (walker.StatementType == HqlSqlWalker.INSERT) @@ -645,12 +652,12 @@ private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlGenerator)); private readonly IASTNode _ast; - private readonly CommonTokenStream _tokens; + private readonly ITokenStream _tokens; private readonly ISessionFactoryImplementor _sfi; private SqlString _sql; private IList<IParameterSpecification> _parameters; - public HqlSqlGenerator(IStatement ast, CommonTokenStream tokens, ISessionFactoryImplementor sfi) + public HqlSqlGenerator(IStatement ast, ITokenStream tokens, ISessionFactoryImplementor sfi) { _ast = (IASTNode) ast; _tokens = tokens; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -273,7 +273,17 @@ return _children[index]; } - public void SetChild(int index, IASTNode newChild) + public IASTNode GetFirstChild() + { + return GetChild(0); + } + + public void SetFirstChild(IASTNode newChild) + { + SetChild(0, newChild); + } + + public void SetChild(int index, IASTNode newChild) { if ((_children == null) || _children.Count <= index) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -360,5 +360,23 @@ { return "FromClause{" + "level=" + _level + "}"; } + + public virtual void Resolve() + { + // Make sure that all from elements registered with this FROM clause are actually in the AST. + var iter = (new ASTIterator(GetFirstChild())).GetEnumerator(); + var childrenInTree = new HashedSet<IASTNode>(); + while (iter.MoveNext()) + { + childrenInTree.Add(iter.Current); + } + foreach (var fromElement in _fromElements) + { + if (!childrenInTree.Contains(fromElement)) + { + throw new SemanticException("Element not in AST: " + fromElement); + } + } + } } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -33,8 +33,7 @@ ret = new SqlNode(payload); break; case HqlSqlWalker.DELETE: - //return DeleteStatement.class; - ret = new SqlNode(payload); + ret = new DeleteStatement(payload); break; case HqlSqlWalker.INSERT: //return InsertStatement.class; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -17,7 +17,9 @@ IASTNode Parent { get; set; } IASTNode NextSibling { get; } IASTNode GetChild(int index); - void SetChild(int index, IASTNode newChild); + IASTNode GetFirstChild(); + void SetFirstChild(IASTNode newChild); + void SetChild(int index, IASTNode newChild); IASTNode AddChild(IASTNode childNode); IASTNode InsertChild(int index, IASTNode child); IASTNode AddSibling(IASTNode newSibling); @@ -30,7 +32,7 @@ // TODO - not sure we need this... IToken Token { get; } - + string ToStringTree(); } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/ASTIterator.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -13,14 +13,16 @@ [CLSCompliant(false)] public class ASTIterator : IEnumerable<IASTNode> { + private readonly Stack<IASTNode> _stack = new Stack<IASTNode>(); private IASTNode _current; - private readonly Stack<IASTNode> _stack = new Stack<IASTNode>(); public ASTIterator(IASTNode tree) { _current = tree; } + #region IEnumerable<IASTNode> Members + public IEnumerator<IASTNode> GetEnumerator() { Down(); @@ -45,17 +47,20 @@ } } - private void Down() { - while ( _current != null && _current.ChildCount > 0) + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + private void Down() + { + while (_current != null && _current.ChildCount > 0) { _stack.Push(_current); _current = _current.GetChild(0); } } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/CollectingNodeVisitor.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -4,6 +4,11 @@ namespace NHibernate.Hql.Ast.ANTLR.Util { + /// <summary> + /// Filters nodes in/out of a tree. + /// </summary> + /// <param name="node">The node to check.</param> + /// <returns>true to keep the node, false if the node should be filtered out.</returns> [CLSCompliant(false)] public delegate bool FilterPredicate(IASTNode node); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/SyntheticAndFactory.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -1,11 +1,12 @@ using System; -using Antlr.Runtime.Tree; using log4net; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; +using NHibernate.Persister.Entity; +using System.Collections.Generic; namespace NHibernate.Hql.Ast.ANTLR.Util { @@ -143,5 +144,45 @@ { return _hqlSqlWalker.ASTFactory.CreateNode(tokenType, text); } + + public virtual void AddDiscriminatorWhereFragment(IRestrictableStatement statement, IQueryable persister, IDictionary<string, IFilter> enabledFilters, string alias) + { + string whereFragment = persister.FilterFragment(alias, enabledFilters).Trim(); + if (string.Empty.Equals(whereFragment)) + { + return; + } + if (whereFragment.StartsWith("and")) + { + whereFragment = whereFragment.Substring(4); + } + + // Need to parse off the column qualifiers; this is assuming (which is true as of now) + // that this is only used from update and delete HQL statement parsing + whereFragment = StringHelper.Replace(whereFragment, persister.GenerateFilterConditionAlias(alias) + ".", ""); + + // Note: this simply constructs a "raw" SQL_TOKEN representing the + // where fragment and injects this into the tree. This "works"; + // however it is probably not the best long-term solution. + // + // At some point we probably want to apply an additional grammar to + // properly tokenize this where fragment into constituent parts + // focused on the operators embedded within the fragment. + IASTNode discrimNode = Create(HqlSqlWalker.SQL_TOKEN, whereFragment); + + if (statement.WhereClause.ChildCount == 0) + { + statement.WhereClause.SetFirstChild(discrimNode); + } + else + { + IASTNode and = Create(HqlSqlWalker.AND, "{and}"); + IASTNode currentFirstChild = statement.WhereClause.GetFirstChild(); + and.SetFirstChild(discrimNode); + and.AddChild(currentFirstChild); + statement.WhereClause.SetFirstChild(and); + } + } + } } Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs 2009-05-02 05:10:00 UTC (rev 4223) @@ -6,7 +6,7 @@ [TestFixture] public class HqlBulkOperations: BaseFixture { - [Test, Ignore("Not supported yet.")] + [Test] public void SimpleDelete() { using (var s = OpenSession()) Modified: trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-05-01 14:55:28 UTC (rev 4222) +++ trunk/nhibernate/src/NHibernate.Test/BulkManipulation/SimpleClass.hbm.xml 2009-05-02 05:10:00 UTC (rev 4223) @@ -3,7 +3,7 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.BulkManipulation"> - <class name="SimpleClass"> + <class name="SimpleClass" table="TSIMPLE"> <id type="int"> <generator class="native" /> </id> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 14:22:19
|
Revision: 4230 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4230&view=rev Author: fabiomaulo Date: 2009-05-04 13:34:20 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -1,5 +1,8 @@ using System; +using NHibernate.Action; using NHibernate.Engine; +using NHibernate.Event; +using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using log4net; @@ -21,5 +24,19 @@ public abstract SqlString[] SqlStatements{get;} public abstract int Execute(QueryParameters parameters, ISessionImplementor session); + + protected abstract IQueryable[] AffectedQueryables { get; } + + protected virtual void CoordinateSharedCacheCleanup(ISessionImplementor session) + { + var action = new BulkOperationCleanupAction(session, AffectedQueryables); + + action.Init(); + + if (session.IsEventSource) + { + ((IEventSource)session).ActionQueue.AddAction(action); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -56,7 +56,7 @@ public override int Execute(QueryParameters parameters, ISessionImplementor session) { - //CoordinateSharedCacheCleanup(session); + CoordinateSharedCacheCleanup(session); IDbCommand st = null; RowSelection selection = parameters.RowSelection; @@ -101,5 +101,10 @@ "could not execute update query", sql); } } + + protected override IQueryable[] AffectedQueryables + { + get { return new[] { persister }; } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 05:09:41 UTC (rev 4229) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 13:34:20 UTC (rev 4230) @@ -162,6 +162,6 @@ txn.Commit(); s.Close(); } - } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 22:01:27
|
Revision: 4231 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4231&view=rev Author: fabiomaulo Date: 2009-05-04 22:01:16 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (multi-table support) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -414,5 +414,12 @@ manager.flushingFromDtcTransaction = false; } } + + public IDbCommand CreateCommand() + { + var result = GetConnection().CreateCommand(); + Transaction.Enlist(result); + return result; + } } } Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -276,6 +276,21 @@ get { return true; } } + public override bool SupportsTemporaryTables + { + get { return true; } + } + + public override string GenerateTemporaryTableName(string baseTableName) + { + return "#" + baseTableName; + } + + public override bool DropTemporaryTableAfterUse() + { + return true; + } + /// <summary> /// /// </summary> Modified: trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -12,7 +12,10 @@ /// <summary> /// Perform the actual work to be done. /// </summary> - /// <param name="connection">The ADP cpnnection to use.</param> + /// <param name="connection">The ADP connection to use.</param> void DoWork(IDbConnection connection); + + // 2009-05-04 Another time we need a TransactionManager to manage isolated + // work for a given connection. } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Engine/TransactionHelper.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -1,4 +1,5 @@ using System.Data; +using System.Data.Common; using NHibernate.Engine.Transaction; using NHibernate.Exceptions; @@ -30,7 +31,7 @@ { generatedValue = owner.DoWorkInCurrentTransaction(connection, null); } - catch (System.Data.OleDb.OleDbException sqle) + catch (DbException sqle) { throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, "could not get or update next value", null); } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -1,10 +1,18 @@ using System; +using System.Data; +using Antlr.Runtime.Tree; using NHibernate.Action; using NHibernate.Engine; +using NHibernate.Engine.Transaction; using NHibernate.Event; +using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using log4net; +using Antlr.Runtime; +using NHibernate.SqlTypes; +using NHibernate.Util; +using NHibernate.AdoNet.Util; namespace NHibernate.Hql.Ast.ANTLR.Exec { @@ -13,20 +21,27 @@ { private readonly ILog log; - protected AbstractStatementExecutor(HqlSqlWalker walker, ILog log) + protected AbstractStatementExecutor(IStatement statement, ILog log) { - Walker = walker; + Statement = statement; + Walker = statement.Walker; this.log = log; } protected HqlSqlWalker Walker { get; private set; } + protected IStatement Statement { get; private set; } - public abstract SqlString[] SqlStatements{get;} + public abstract SqlString[] SqlStatements { get; } public abstract int Execute(QueryParameters parameters, ISessionImplementor session); protected abstract IQueryable[] AffectedQueryables { get; } + protected ISessionFactoryImplementor Factory + { + get{return Walker.SessionFactoryHelper.Factory;} + } + protected virtual void CoordinateSharedCacheCleanup(ISessionImplementor session) { var action = new BulkOperationCleanupAction(session, AffectedQueryables); @@ -38,5 +53,248 @@ ((IEventSource)session).ActionQueue.AddAction(action); } } + + protected SqlString GenerateIdInsertSelect(IQueryable persister, string tableAlias, IASTNode whereClause) + { + var select = new SqlSelectBuilder(Factory); + SelectFragment selectFragment = new SelectFragment(Factory.Dialect) + .AddColumns(tableAlias, persister.IdentifierColumnNames, persister.IdentifierColumnNames); + select.SetSelectClause(selectFragment.ToFragmentString().Substring(2)); + + string rootTableName = persister.TableName; + SqlString fromJoinFragment = persister.FromJoinFragment(tableAlias, true, false); + SqlString whereJoinFragment = persister.WhereJoinFragment(tableAlias, true, false); + + select.SetFromClause(rootTableName + ' ' + tableAlias + fromJoinFragment); + + if (whereJoinFragment == null) + { + whereJoinFragment = SqlString.Empty; + } + else + { + whereJoinFragment = whereJoinFragment.Trim(); + if (whereJoinFragment.StartsWithCaseInsensitive("and ")) + { + whereJoinFragment = whereJoinFragment.Substring(4); + } + } + + SqlString userWhereClause = SqlString.Empty; + if (whereClause.ChildCount != 0) + { + // If a where clause was specified in the update/delete query, use it to limit the + // returned ids here... + try + { + var nodes = new CommonTreeNodeStream(whereClause); + var gen = new SqlGenerator(Factory, nodes); + gen.whereClause(); + userWhereClause = gen.GetSQL().Substring(7); + } + catch (RecognitionException e) + { + throw new HibernateException("Unable to generate id select for DML operation", e); + } + if (whereJoinFragment.Length > 0) + { + whereJoinFragment.Append(" and "); + } + } + + select.SetWhereClause(whereJoinFragment + userWhereClause); + + var insert = new InsertSelect(); + if (Factory.Settings.IsCommentsEnabled) + { + insert.SetComment("insert-select for " + persister.EntityName + " ids"); + } + insert.SetTableName(persister.TemporaryIdTableName); + insert.SetSelect(select); + return insert.ToSqlString(); + } + + protected string GenerateIdSubselect(IQueryable persister) + { + return "select " + StringHelper.Join(", ", persister.IdentifierColumnNames) + " from " + persister.TemporaryIdTableName; + } + + protected virtual void CreateTemporaryTableIfNecessary(IQueryable persister, ISessionImplementor session) + { + // Don't really know all the codes required to adequately decipher returned ADO exceptions here. + // simply allow the failure to be eaten and the subsequent insert-selects/deletes should fail + IIsolatedWork work = new TmpIdTableCreationIsolatedWork(persister, log, session); + if (ShouldIsolateTemporaryTableDDL()) + { + if (Factory.Settings.IsDataDefinitionInTransactionSupported) + { + Isolater.DoIsolatedWork(work, session); + } + else + { + Isolater.DoNonTransactedWork(work, session); + } + } + else + { + work.DoWork(session.ConnectionManager.GetConnection()); + session.ConnectionManager.AfterStatement(); + } + } + + protected virtual bool ShouldIsolateTemporaryTableDDL() + { + bool? dialectVote = Factory.Dialect.PerformTemporaryTableDDLInIsolation(); + if (dialectVote.HasValue) + { + return dialectVote.Value; + } + else + { + return Factory.Settings.IsDataDefinitionImplicitCommit; + } + } + + protected virtual void DropTemporaryTableIfNecessary(IQueryable persister, ISessionImplementor session) + { + if (Factory.Dialect.DropTemporaryTableAfterUse()) + { + IIsolatedWork work = new TmpIdTableDropIsolatedWork(persister, log, session); + + if (ShouldIsolateTemporaryTableDDL()) + { + if (Factory.Settings.IsDataDefinitionInTransactionSupported) + { + Isolater.DoIsolatedWork(work, session); + } + else + { + Isolater.DoNonTransactedWork(work, session); + } + } + else + { + work.DoWork(session.ConnectionManager.GetConnection()); + session.ConnectionManager.AfterStatement(); + } + } + else + { + // at the very least cleanup the data :) + IDbCommand ps = null; + try + { + var commandText = new SqlString("delete from " + persister.TemporaryIdTableName); + ps = session.Batcher.PrepareCommand(CommandType.Text, commandText, new SqlType[0]); + ps.ExecuteNonQuery(); + } + catch (Exception t) + { + log.Warn("unable to cleanup temporary id table after use [" + t + "]"); + } + finally + { + if (ps != null) + { + try + { + session.Batcher.CloseCommand(ps, null); + } + catch (Exception) + { + // ignore + } + } + } + } + } + + private class TmpIdTableCreationIsolatedWork : IIsolatedWork + { + private readonly IQueryable persister; + private readonly ILog log; + private readonly ISessionImplementor session; + + public TmpIdTableCreationIsolatedWork(IQueryable persister, ILog log, ISessionImplementor session) + { + this.persister = persister; + this.log = log; + this.session = session; + } + + public void DoWork(IDbConnection connection) + { + IDbCommand stmnt = null; + try + { + stmnt = session.ConnectionManager.CreateCommand(); + stmnt.CommandText = persister.TemporaryIdTableDDL; + stmnt.ExecuteNonQuery(); + session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); + } + catch (Exception t) + { + log.Debug("unable to create temporary id table [" + t.Message + "]"); + } + finally + { + if (stmnt != null) + { + try + { + stmnt.Dispose(); + } + catch (Exception) + { + // ignore + } + } + } + } + } + + private class TmpIdTableDropIsolatedWork : IIsolatedWork + { + public TmpIdTableDropIsolatedWork(IQueryable persister, ILog log, ISessionImplementor session) + { + this.persister = persister; + this.log = log; + this.session = session; + } + + private readonly IQueryable persister; + private readonly ILog log; + private readonly ISessionImplementor session; + + public void DoWork(IDbConnection connection) + { + IDbCommand stmnt = null; + try + { + stmnt = session.ConnectionManager.CreateCommand(); + stmnt.CommandText = "drop table " + persister.TemporaryIdTableName; + stmnt.ExecuteNonQuery(); + session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); + } + catch (Exception t) + { + log.Warn("unable to drop temporary id table after use [" + t.Message + "]"); + } + finally + { + if (stmnt != null) + { + try + { + stmnt.Dispose(); + } + catch (Exception) + { + // ignore + } + } + } + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -18,11 +18,11 @@ public class BasicExecutor : AbstractStatementExecutor { private readonly IQueryable persister; - private static readonly ILog log = LogManager.GetLogger(typeof(QueryTranslatorImpl)); + private static readonly ILog log = LogManager.GetLogger(typeof(BasicExecutor)); private readonly SqlString sql; public BasicExecutor(IStatement statement, ITokenStream tokenStream, IQueryable persister) - : base(statement.Walker, log) + : base(statement, log) { this.persister = persister; try @@ -41,14 +41,6 @@ protected IList<IParameterSpecification> Parameters{get;private set;} - protected ISessionFactoryImplementor Factory - { - get - { - return Walker.SessionFactoryHelper.Factory; - } - } - public override SqlString[] SqlStatements { get { return new[] {sql}; } @@ -72,7 +64,8 @@ } st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); IEnumerator<IParameterSpecification> paramSpecifications = Parameters.GetEnumerator(); - int pos = 1; + // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) + int pos = 0; while (paramSpecifications.MoveNext()) { var paramSpec = paramSpecifications.Current; Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; +using NHibernate.Util; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + public class MultiTableDeleteExecutor : AbstractStatementExecutor + { + private static readonly ILog log = LogManager.GetLogger(typeof(MultiTableDeleteExecutor)); + private readonly IQueryable persister; + private readonly SqlString idInsertSelect; + private readonly SqlString[] deletes; + + public MultiTableDeleteExecutor(IStatement statement) + : base(statement, log) + { + if (!Factory.Dialect.SupportsTemporaryTables) + { + throw new HibernateException("cannot perform multi-table deletes using dialect not supporting temp tables"); + } + + var deleteStatement = (DeleteStatement) statement; + + FromElement fromElement = deleteStatement.FromClause.GetFromElement(); + string bulkTargetAlias = fromElement.TableAlias; + persister = fromElement.Queryable; + + idInsertSelect = GenerateIdInsertSelect(persister, bulkTargetAlias, deleteStatement.WhereClause); + log.Debug("Generated ID-INSERT-SELECT SQL (multi-table delete) : " + idInsertSelect); + + string[] tableNames = persister.ConstraintOrderedTableNameClosure; + string[][] columnNames = persister.ContraintOrderedTableKeyColumnClosure; + string idSubselect = GenerateIdSubselect(persister); + + deletes = new SqlString[tableNames.Length]; + for (int i = tableNames.Length - 1; i >= 0; i--) + { + // TODO : an optimization here would be to consider cascade deletes and not gen those delete statements; + // the difficulty is the ordering of the tables here vs the cascade attributes on the persisters -> + // the table info gotten here should really be self-contained (i.e., a class representation + // defining all the needed attributes), then we could then get an array of those + SqlDeleteBuilder delete = new SqlDeleteBuilder(Factory.Dialect, Factory) + .SetTableName(tableNames[i]) + .SetWhere("(" + StringHelper.Join(", ", columnNames[i]) + ") IN (" + idSubselect + ")"); + if (Factory.Settings.IsCommentsEnabled) + { + delete.SetComment("bulk delete"); + } + + deletes[i] = delete.ToSqlString(); + } + } + + public override SqlString[] SqlStatements + { + get { return deletes; } + } + + public override int Execute(QueryParameters parameters, ISessionImplementor session) + { + CoordinateSharedCacheCleanup(session); + + CreateTemporaryTableIfNecessary(persister, session); + + try + { + // First, save off the pertinent ids, saving the number of pertinent ids for return + IDbCommand ps = null; + int resultCount; + try + { + try + { + var parameterTypes = new List<SqlType>(Walker.Parameters.Count); + foreach (var parameterSpecification in Walker.Parameters) + { + parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); + } + + ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, parameterTypes.ToArray()); + IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); + // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) + int pos = 0; + while (paramSpecifications.MoveNext()) + { + var paramSpec = paramSpecifications.Current; + pos += paramSpec.Bind(ps, parameters, session, pos); + } + resultCount = session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not insert/select ids for bulk delete", idInsertSelect); + } + + // Start performing the deletes + for (int i = 0; i < deletes.Length; i++) + { + try + { + try + { + ps = session.Batcher.PrepareCommand(CommandType.Text, deletes[i], new SqlType[0]); + session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "error performing bulk delete", deletes[i]); + } + } + + return resultCount; + } + finally + { + DropTemporaryTableIfNecessary(persister, session); + } + } + + protected override IQueryable[] AffectedQueryables + { + get { return new[] { persister }; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -403,8 +403,7 @@ IQueryable persister = fromElement.Queryable; if (persister.IsMultiTable) { - throw new NotSupportedException(); - //return new MultiTableDeleteExecutor(walker); + return new MultiTableDeleteExecutor(statement); } else { @@ -420,8 +419,7 @@ // even here, if only properties mapped to the "base table" are referenced // in the set and where clauses, this could be handled by the BasicDelegate. // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate - throw new NotSupportedException(); - //return new MultiTableUpdateExecutor(walker); + return new MultiTableDeleteExecutor(statement); } else { Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-04 22:01:16 UTC (rev 4231) @@ -483,6 +483,7 @@ <Compile Include="Hql\Ast\ANTLR\Exec\AbstractStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\BasicExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\MultiTableDeleteExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs" /> @@ -584,6 +585,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\JoinProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> + <Compile Include="SqlCommand\InsertSelect.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> Added: trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -0,0 +1,79 @@ +using System.Collections.Generic; +using log4net; +using NHibernate.Engine; + +namespace NHibernate.SqlCommand +{ + public class InsertSelect : ISqlStringBuilder + { + private static readonly ILog log = LogManager.GetLogger(typeof(InsertSelect)); + + private readonly ISessionFactoryImplementor factory; + private string tableName; + private string comment; + private readonly List<string> columnNames = new List<string>(); + private SqlSelectBuilder select; + + public virtual InsertSelect SetTableName(string tableName) + { + this.tableName = tableName; + return this; + } + + public virtual InsertSelect SetComment(string comment) + { + this.comment = comment; + return this; + } + + public virtual InsertSelect AddColumn(string columnName) + { + columnNames.Add(columnName); + return this; + } + + public virtual InsertSelect AddColumns(string[] columnNames) + { + this.columnNames.AddRange(columnNames); + return this; + } + + public virtual InsertSelect SetSelect(SqlSelectBuilder select) + { + this.select = select; + return this; + } + + public SqlString ToSqlString() + { + if (tableName == null) + throw new HibernateException("no table name defined for insert-select"); + if (select == null) + throw new HibernateException("no select defined for insert-select"); + + var buf = new SqlStringBuilder(columnNames.Count + 4); + if (comment != null) + { + buf.Add("/* " + comment + " */ "); + } + buf.Add("insert into ").Add(tableName); + if (!(columnNames.Count == 0)) + { + buf.Add(" ("); + bool commaNeeded= false; + foreach (var columnName in columnNames) + { + if(commaNeeded) + { + buf.Add(", "); + } + buf.Add(columnName); + commaNeeded = true; + } + buf.Add(")"); + } + buf.Add(" ").Add(select.ToStatementString()); + return buf.ToSqlString(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -15,7 +15,7 @@ private static readonly ILog log = LogManager.GetLogger(typeof(SqlDeleteBuilder)); private string tableName; - private readonly List<SqlString> whereStrings = new List<SqlString>(); + private List<SqlString> whereStrings = new List<SqlString>(); private readonly List<SqlType> parameterTypes = new List<SqlType>(); private string comment; @@ -81,7 +81,6 @@ return this; } - public SqlDeleteBuilder AddWhereFragment(string columnName, SqlType type, string op) { if (!string.IsNullOrEmpty(columnName)) @@ -91,6 +90,7 @@ } return this; } + /// <summary> /// Adds a string to the WhereFragement /// </summary> @@ -104,6 +104,15 @@ return this; } + public virtual SqlDeleteBuilder SetWhere(string whereSql) + { + if (StringHelper.IsNotEmpty(whereSql)) + { + whereStrings = new List<SqlString>(new[]{ new SqlString(whereSql)}); + } + return this; + } + #region ISqlStringBuilder Members public SqlString ToSqlString() Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -207,7 +207,9 @@ // plus the number of parts in outerJoinsAfterWhere SqlString. // 1 = the whereClause // 2 = the "ORDER BY" and orderByClause - int initialCapacity = 4 + outerJoinsAfterFrom.Count + 1 + outerJoinsAfterWhere.Count + 1 + 2; + var joinAfterFrom = outerJoinsAfterFrom != null ? outerJoinsAfterFrom.Count : 0; + var joinAfterWhere = outerJoinsAfterWhere != null ? outerJoinsAfterWhere.Count : 0; + int initialCapacity = 4 + joinAfterFrom + 1 + joinAfterWhere + 1 + 2; if (!string.IsNullOrEmpty(comment)) initialCapacity++; @@ -218,9 +220,13 @@ sqlBuilder.Add("SELECT ") .Add(selectClause) .Add(" FROM ") - .Add(fromClause) - .Add(outerJoinsAfterFrom); + .Add(fromClause); + if (StringHelper.IsNotEmpty(outerJoinsAfterFrom)) + { + sqlBuilder.Add(outerJoinsAfterFrom); + } + if (StringHelper.IsNotEmpty(whereClause) || StringHelper.IsNotEmpty(outerJoinsAfterWhere)) { sqlBuilder.Add(" WHERE "); Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Animal.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -60,5 +60,15 @@ get { return serialNumber; } set { serialNumber = value; } } + + public virtual void AddOffspring(Animal offSpring) + { + if (offspring == null) + { + offspring = new HashedSet(); + } + + offspring.Add(offSpring); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:01:16 UTC (rev 4231) @@ -33,7 +33,7 @@ #endregion - [Test, Ignore("Not supported")] + [Test] public void DeleteRestrictedOnManyToOne() { var data = new TestData(this); @@ -95,12 +95,12 @@ Frog = new Animal { BodyWeight = 34, Description = "Frog" }; Polliwog.Father = Frog; - Frog.Offspring.Add(Polliwog); + Frog.AddOffspring(Polliwog); Butterfly = new Animal { BodyWeight = 9, Description = "Butterfly" }; Catepillar.Mother = Butterfly; - Butterfly.Offspring.Add(Catepillar); + Butterfly.AddOffspring(Catepillar); s.Save(Frog); s.Save(Polliwog); Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-04 13:34:20 UTC (rev 4230) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/Vehicle.hbm.xml 2009-05-04 22:01:16 UTC (rev 4231) @@ -6,7 +6,7 @@ <!-- Vehicle represents an abstract root of a union-subclass hierarchy --> <class name="Vehicle" abstract="true"> <id name="id" access="field" type="long"> - <generator class="increment"/> + <generator class="hilo"/> </id> <property name="Vin" type="string"/> <property name="Owner" type="string"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-04 23:03:30
|
Revision: 4237 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4237&view=rev Author: fabiomaulo Date: 2009-05-04 23:03:21 +0000 (Mon, 04 May 2009) Log Message: ----------- Continue porting HQL executable (delete tests with joined table) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-04 22:45:13 UTC (rev 4236) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-04 23:03:21 UTC (rev 4237) @@ -280,7 +280,14 @@ public void SetFirstChild(IASTNode newChild) { - SetChild(0, newChild); + if (_children == null || _children.Count == 0) + { + AddChild(newChild); + } + else + { + _children[0] = newChild; + } } public void SetChild(int index, IASTNode newChild) Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 22:45:13 UTC (rev 4236) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-04 23:03:21 UTC (rev 4237) @@ -34,6 +34,30 @@ #endregion [Test] + public void DeleteOnJoinedSubclass() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("delete Mammal where bodyWeight > 150").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + + count = s.CreateQuery("delete Mammal").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + + count = s.CreateQuery("delete SubMulti").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(0), "Incorrect deletion count on joined subclass"); + + t.Commit(); + s.Close(); + + data.Cleanup(); + } + + [Test] public void DeleteOnMappedJoin() { var data = new TestData(this); @@ -44,7 +68,7 @@ int count = s.CreateQuery("delete Joiner where joinedName = :joinedName") .SetString("joinedName", "joined-name").ExecuteUpdate(); - Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass"); + Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined class"); t.Commit(); s.Close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-05 04:15:29
|
Revision: 4242 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4242&view=rev Author: fabiomaulo Date: 2009-05-05 04:15:19 +0000 (Tue, 05 May 2009) Log Message: ----------- preparing porting for insert/update HQL Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InsertStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-04 23:46:25 UTC (rev 4241) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-05 04:15:19 UTC (rev 4242) @@ -14,6 +14,7 @@ namespace NHibernate.Hql.Ast.ANTLR.Exec { + [CLSCompliant(false)] public class MultiTableDeleteExecutor : AbstractStatementExecutor { private static readonly ILog log = LogManager.GetLogger(typeof(MultiTableDeleteExecutor)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-04 23:46:25 UTC (rev 4241) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-05 04:15:19 UTC (rev 4242) @@ -11,7 +11,7 @@ [CLSCompliant(false)] public class DeleteStatement : AbstractRestrictableStatement { - private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); + private static readonly ILog log = LogManager.GetLogger(typeof(DeleteStatement)); public DeleteStatement(IToken token) : base(token) {} Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-04 23:46:25 UTC (rev 4241) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-05 04:15:19 UTC (rev 4242) @@ -29,15 +29,13 @@ ret = new QueryNode(payload); break; case HqlSqlWalker.UPDATE: - //return UpdateStatement.class; - ret = new SqlNode(payload); + ret = new UpdateStatement(payload); break; case HqlSqlWalker.DELETE: ret = new DeleteStatement(payload); break; case HqlSqlWalker.INSERT: - //return InsertStatement.class; - ret = new SqlNode(payload); + ret = new InsertStatement(payload); break; case HqlSqlWalker.INTO: ret = new IntoClause(payload); @@ -57,7 +55,7 @@ case HqlSqlWalker.INDEX_OP: ret = new IndexNode(payload); break; - // Alias references and identifiers use the same node class. + // Alias references and identifiers use the same node class. case HqlSqlWalker.ALIAS_REF: case HqlSqlWalker.IDENT: ret = new IdentNode(payload); @@ -154,7 +152,6 @@ default: ret = new SqlNode(payload); break; - } Initialise(ret); @@ -163,11 +160,11 @@ public override object DupNode(object t) { - IASTNode node = t as IASTNode; + var node = t as IASTNode; if (node != null) { - IASTNode dupped = (IASTNode)Create(node.Token); + var dupped = (IASTNode) Create(node.Token); dupped.Parent = node.Parent; @@ -179,16 +176,16 @@ } } - void Initialise(object node) + private void Initialise(object node) { - IInitializableNode initableNode = node as IInitializableNode; + var initableNode = node as IInitializableNode; if (initableNode != null) { initableNode.Initialize(_walker); } - ISessionFactoryAwareNode sessionNode = node as ISessionFactoryAwareNode; + var sessionNode = node as ISessionFactoryAwareNode; if (sessionNode != null) { @@ -196,4 +193,4 @@ } } } -} +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InsertStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InsertStatement.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InsertStatement.cs 2009-05-05 04:15:19 UTC (rev 4242) @@ -0,0 +1,45 @@ +using System; +using Antlr.Runtime; + +namespace NHibernate.Hql.Ast.ANTLR.Tree +{ + /// <summary> + /// Defines a top-level AST node representing an HQL "insert select" statement. + /// </summary> + [Serializable] + [CLSCompliant(false)] + public class InsertStatement : AbstractStatement + { + public InsertStatement(IToken token) : base(token) {} + public override bool NeedsExecutor + { + get { return true; } + } + + public override int StatementType + { + get { return HqlSqlWalker.INSERT; } + } + + /// <summary> Retreive this insert statement's into-clause. </summary> + /// <returns> The into-clause </returns> + public IntoClause IntoClause + { + get{return (IntoClause)GetFirstChild();} + } + + /// <summary> Retreive this insert statement's select-clause.</summary> + /// <returns> The select-clause. </returns> + public SelectClause SelectClause + { + get{return ((QueryNode)IntoClause.NextSibling).GetSelectClause();} + } + + /// <summary> Performs detailed semantic validation on this insert statement tree. </summary> + /// <exception cref="QueryException">Indicates validation failure.</exception> + public virtual void Validate() + { + IntoClause.ValidateTypes(SelectClause); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs 2009-05-05 04:15:19 UTC (rev 4242) @@ -0,0 +1,44 @@ +using System; +using Antlr.Runtime; +using log4net; +using NHibernate.Hql.Ast.ANTLR.Util; + +namespace NHibernate.Hql.Ast.ANTLR.Tree +{ + /// <summary> + /// Defines a top-level AST node representing an HQL update statement. + /// </summary> + [Serializable] + [CLSCompliant(false)] + public class UpdateStatement : AbstractRestrictableStatement + { + private static readonly ILog log = LogManager.GetLogger(typeof (UpdateStatement)); + + public UpdateStatement(IToken token) : base(token) {} + + public override bool NeedsExecutor + { + get { return true; } + } + + public override int StatementType + { + get { return HqlSqlWalker.UPDATE; } + } + + public IASTNode SetClause + { + get { return ASTUtil.FindTypeInChildren(this, HqlSqlWalker.SET); } + } + + protected override ILog GetLog() + { + return log; + } + + protected override int GetWhereClauseParentTokenType() + { + return HqlSqlWalker.SET; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-04 23:46:25 UTC (rev 4241) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-05 04:15:19 UTC (rev 4242) @@ -497,6 +497,8 @@ <Compile Include="Hql\Ast\ANTLR\InvalidWithClauseException.cs" /> <Compile Include="Hql\Ast\ANTLR\IParseErrorHandler.cs" /> <Compile Include="Hql\Ast\ANTLR\Loader\QueryLoader.cs" /> + <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> + <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> <Compile Include="Param\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> <Compile Include="Param\CollectionFilterKeyParameterSpecification.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-05 06:10:40
|
Revision: 4243 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4243&view=rev Author: fabiomaulo Date: 2009-05-05 06:10:29 +0000 (Tue, 05 May 2009) Log Message: ----------- Continue porting HQL executable (update) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs 2009-05-05 06:10:29 UTC (rev 4243) @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; +using System.Data; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Param; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; +using NHibernate.Util; + +namespace NHibernate.Hql.Ast.ANTLR.Exec +{ + [CLSCompliant(false)] + public class MultiTableUpdateExecutor : AbstractStatementExecutor + { + private static readonly ILog log = LogManager.GetLogger(typeof(MultiTableDeleteExecutor)); + private readonly IQueryable persister; + private readonly SqlString idInsertSelect; + private readonly SqlString[] updates; + private readonly IParameterSpecification[][] hqlParameters; + + public MultiTableUpdateExecutor(IStatement statement, ILog log) : base(statement, log) + { + if (!Factory.Dialect.SupportsTemporaryTables) + { + throw new HibernateException("cannot perform multi-table updates using dialect not supporting temp tables"); + } + var updateStatement = (UpdateStatement)statement; + + FromElement fromElement = updateStatement.FromClause.GetFromElement(); + string bulkTargetAlias = fromElement.TableAlias; + persister = fromElement.Queryable; + + idInsertSelect = GenerateIdInsertSelect(persister, bulkTargetAlias, updateStatement.WhereClause); + log.Debug("Generated ID-INSERT-SELECT SQL (multi-table update) : " + idInsertSelect); + + string[] tableNames = persister.ConstraintOrderedTableNameClosure; + string[][] columnNames = persister.ContraintOrderedTableKeyColumnClosure; + + string idSubselect = GenerateIdSubselect(persister); + var assignmentSpecifications = Walker.AssignmentSpecifications; + + updates = new SqlString[tableNames.Length]; + hqlParameters = new IParameterSpecification[tableNames.Length][]; + for (int tableIndex = 0; tableIndex < tableNames.Length; tableIndex++) + { + bool affected = false; + var parameterList = new List<IParameterSpecification>(); + SqlUpdateBuilder update = new SqlUpdateBuilder(Factory.Dialect, Factory) + .SetTableName(tableNames[tableIndex]) + .SetWhere("(" + StringHelper.Join(", ", columnNames[tableIndex]) + ") IN (" + idSubselect + ")"); + + if (Factory.Settings.IsCommentsEnabled) + { + update.SetComment("bulk update"); + } + foreach (var specification in assignmentSpecifications) + { + if (specification.AffectsTable(tableNames[tableIndex])) + { + affected = true; + update.AppendAssignmentFragment(specification.SqlAssignmentFragment); + if (specification.Parameters != null) + { + for (int paramIndex = 0; paramIndex < specification.Parameters.Length; paramIndex++) + { + parameterList.Add(specification.Parameters[paramIndex]); + } + } + } + } + if (affected) + { + updates[tableIndex] = update.ToSqlString(); + hqlParameters[tableIndex] = parameterList.ToArray(); + } + } + } + + public override SqlString[] SqlStatements + { + get { return updates; } + } + + public override int Execute(QueryParameters parameters, ISessionImplementor session) + { + CoordinateSharedCacheCleanup(session); + + CreateTemporaryTableIfNecessary(persister, session); + + try + { + // First, save off the pertinent ids, as the return value + IDbCommand ps = null; + int resultCount; + try + { + try + { + var parameterTypes = new List<SqlType>(Walker.Parameters.Count); + foreach (var parameterSpecification in Walker.Parameters) + { + parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); + } + + ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, parameterTypes.ToArray()); + + int parameterStart = Walker.NumberOfParametersInSetClause; + + var allParams = Walker.Parameters; + + IEnumerator<IParameterSpecification> whereParams = + (new List<IParameterSpecification>(allParams)).GetRange(parameterStart, allParams.Count - parameterStart). + GetEnumerator(); + // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) + int pos = 0; + while (whereParams.MoveNext()) + { + var paramSpec = whereParams.Current; + pos += paramSpec.Bind(ps, parameters, session, pos); + } + resultCount = session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (System.Data.OleDb.OleDbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not insert/select ids for bulk update", idInsertSelect); + } + + // Start performing the updates + for (int i = 0; i < updates.Length; i++) + { + if (updates[i] == null) + { + continue; + } + try + { + try + { + ps = session.Batcher.PrepareCommand(CommandType.Text, updates[i], new SqlType[0]); + + if (hqlParameters[i] != null) + { + int position = 1; // ADO params are 0-based + for (int x = 0; x < hqlParameters[i].Length; x++) + { + position += hqlParameters[i][x].Bind(ps, parameters, session, position); + } + } + session.Batcher.ExecuteNonQuery(ps); + } + finally + { + if (ps != null) + { + session.Batcher.CloseCommand(ps, null); + } + } + } + catch (System.Data.OleDb.OleDbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "error performing bulk update", updates[i]); + } + } + + return resultCount; + } + finally + { + DropTemporaryTableIfNecessary(persister, session); + } + } + + protected override IQueryable[] AffectedQueryables + { + get { return new[] { persister }; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-05 04:15:19 UTC (rev 4242) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-05 06:10:29 UTC (rev 4243) @@ -53,6 +53,8 @@ private IParseErrorHandler _parseErrorHandler = new ErrorCounter(); private IASTFactory _nodeFactory; + private readonly List<AssignmentSpecification> assignmentSpecifications = new List<AssignmentSpecification>(); + private int numberOfParametersInSetClause; public HqlSqlWalker(QueryTranslatorImpl qti, ISessionFactoryImplementor sfi, @@ -68,6 +70,16 @@ _collectionFilterRole = collectionRole; } + public IList<AssignmentSpecification> AssignmentSpecifications + { + get { return assignmentSpecifications; } + } + + public int NumberOfParametersInSetClause + { + get { return numberOfParametersInSetClause; } + } + public IParseErrorHandler ParseErrorHandler { get { return _parseErrorHandler; } @@ -333,11 +345,31 @@ constructorNode.Prepare(); } - static void EvaluateAssignment(IASTNode eq) + protected void EvaluateAssignment(IASTNode eq) { - throw new NotImplementedException(); // DML + PrepareLogicOperator(eq); + IQueryable persister = CurrentFromClause.GetFromElement().Queryable; + EvaluateAssignment(eq, persister, -1); } + private void EvaluateAssignment(IASTNode eq, IQueryable persister, int targetIndex) + { + if (persister.IsMultiTable) + { + // no need to even collect this information if the persister is considered multi-table + var specification = new AssignmentSpecification(eq, persister); + if (targetIndex >= 0) + { + assignmentSpecifications.Insert(targetIndex, specification); + } + else + { + assignmentSpecifications.Add(specification); + } + numberOfParametersInSetClause += specification.Parameters.Length; + } + } + void BeforeSelectClause() { // Turn off includeSubclasses on all FromElements. Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-05 06:10:29 UTC (rev 4243) @@ -0,0 +1,143 @@ +using System; +using Antlr.Runtime.Tree; +using Iesi.Collections.Generic; +using NHibernate.Engine; +using NHibernate.Hql.Ast.ANTLR.Util; +using NHibernate.Param; +using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; + +namespace NHibernate.Hql.Ast.ANTLR.Tree +{ + /// <summary> + /// Encapsulates the information relating to an individual assignment within the + /// set clause of an HQL update statement. This information is used during execution + /// of the update statements when the updates occur against "multi-table" stuff. + /// </summary> + [CLSCompliant(false)] + public class AssignmentSpecification + { + private readonly IASTNode eq; + private readonly ISessionFactoryImplementor factory; + private readonly ISet<string> tableNames; + private readonly IParameterSpecification[] hqlParameters; + private SqlString sqlAssignmentString; + + public AssignmentSpecification(IASTNode eq, IQueryable persister) + { + if (eq.Type != HqlSqlWalker.EQ) + { + throw new QueryException("assignment in set-clause not associated with equals"); + } + + this.eq = eq; + factory = persister.Factory; + + // Needed to bump this up to DotNode, because that is the only thing which currently + // 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(); + var rhs = (SqlNode)lhs.NextSibling; + + ValidateLhs(lhs); + + string propertyPath = lhs.PropertyPath; + var temp = new HashedSet<string>(); + // yuck! + var usep = persister as UnionSubclassEntityPersister; + if (usep!=null) + { + temp.AddAll(persister.ConstraintOrderedTableNameClosure); + } + else + { + temp.Add(persister.GetSubclassTableName(persister.GetSubclassPropertyTableNumber(propertyPath))); + } + tableNames = new ImmutableSet<string>(temp); + + if (rhs == null) + { + hqlParameters = new IParameterSpecification[0]; + } + else if (IsParam(rhs)) + { + hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; + } + else + { + var parameterList = ASTUtil.CollectChildren(rhs, IsParam); + hqlParameters = new IParameterSpecification[parameterList.Count]; + int i = 0; + foreach (ParameterNode parameterNode in parameterList) + { + hqlParameters[i++] = parameterNode.HqlParameterSpecification; + } + } + } + public bool AffectsTable(string tableName) + { + return tableNames.Contains(tableName); + } + + private static bool IsParam(IASTNode node) + { + return node.Type == HqlSqlWalker.PARAM || node.Type == HqlSqlWalker.NAMED_PARAM; + } + + private static void ValidateLhs(FromReferenceNode lhs) + { + // make sure the lhs is "assignable"... + if (!lhs.IsResolved) + { + throw new NotSupportedException("cannot validate assignablity of unresolved node"); + } + + if (lhs.DataType.IsCollectionType) + { + throw new QueryException("collections not assignable in update statements"); + } + else if (lhs.DataType.IsComponentType) + { + throw new QueryException("Components currently not assignable in update statements"); + } + else if (lhs.DataType.IsEntityType) + { + // currently allowed... + } + + // TODO : why aren't these the same? + if (lhs.GetImpliedJoin() != null || lhs.FromElement.IsImplied) + { + throw new QueryException("Implied join paths are not assignable in update statements"); + } + } + + public IParameterSpecification[] Parameters + { + get{return hqlParameters;} + } + + public SqlString SqlAssignmentFragment + { + get + { + if (sqlAssignmentString == null) + { + try + { + var gen = new SqlGenerator(factory, new CommonTreeNodeStream(eq)); + gen.comparisonExpr(false); // false indicates to not generate parens around the assignment + sqlAssignmentString = gen.GetSQL(); + } + catch (Exception t) + { + throw new QueryException("cannot interpret set-clause assignment", t); + } + } + return sqlAssignmentString; + } + + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-05 04:15:19 UTC (rev 4242) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-05 06:10:29 UTC (rev 4243) @@ -484,6 +484,7 @@ <Compile Include="Hql\Ast\ANTLR\Exec\BasicExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\IStatementExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Exec\MultiTableDeleteExecutor.cs" /> + <Compile Include="Hql\Ast\ANTLR\Exec\MultiTableUpdateExecutor.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlLexer.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlParser.cs" /> <Compile Include="Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs" /> @@ -497,6 +498,7 @@ <Compile Include="Hql\Ast\ANTLR\InvalidWithClauseException.cs" /> <Compile Include="Hql\Ast\ANTLR\IParseErrorHandler.cs" /> <Compile Include="Hql\Ast\ANTLR\Loader\QueryLoader.cs" /> + <Compile Include="Hql\Ast\ANTLR\Tree\AssignmentSpecification.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> Modified: trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs 2009-05-05 04:15:19 UTC (rev 4242) +++ trunk/nhibernate/src/NHibernate/SqlCommand/InsertSelect.cs 2009-05-05 06:10:29 UTC (rev 4243) @@ -1,6 +1,5 @@ using System.Collections.Generic; using log4net; -using NHibernate.Engine; namespace NHibernate.SqlCommand { @@ -8,7 +7,6 @@ { private static readonly ILog log = LogManager.GetLogger(typeof(InsertSelect)); - private readonly ISessionFactoryImplementor factory; private string tableName; private string comment; private readonly List<string> columnNames = new List<string>(); Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs 2009-05-05 04:15:19 UTC (rev 4242) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs 2009-05-05 06:10:29 UTC (rev 4243) @@ -20,8 +20,9 @@ // columns-> (ColumnName, Value) or (ColumnName, SqlType) for parametrized column private readonly LinkedHashMap<string, object> columns = new LinkedHashMap<string, object>(); - private readonly List<SqlString> whereStrings = new List<SqlString>(); + private List<SqlString> whereStrings = new List<SqlString>(); private readonly List<SqlType> whereParameterTypes = new List<SqlType>(); + private SqlString assignments; public SqlUpdateBuilder(Dialect.Dialect dialect, IMapping mapping) : base(dialect, mapping) {} @@ -120,6 +121,28 @@ return this; } + public SqlUpdateBuilder AppendAssignmentFragment(SqlString fragment) + { + if (assignments == null) + { + assignments = fragment; + } + else + { + assignments.Append(", ").Append(fragment); + } + return this; + } + + public SqlUpdateBuilder SetWhere(string whereSql) + { + if (StringHelper.IsNotEmpty(whereSql)) + { + whereStrings = new List<SqlString>(new[] { new SqlString(whereSql) }); + } + return this; + } + /// <summary> /// Sets the IdentityColumn for the <c>UPDATE</c> sql to use. /// </summary> @@ -229,7 +252,7 @@ if (!string.IsNullOrEmpty(comment)) initialCapacity++; - SqlStringBuilder sqlBuilder = new SqlStringBuilder(initialCapacity + 2); + var sqlBuilder = new SqlStringBuilder(initialCapacity + 2); if (!string.IsNullOrEmpty(comment)) sqlBuilder.Add("/* " + comment + " */ "); @@ -237,6 +260,7 @@ .Add(tableName) .Add(" SET "); + bool assignmentsAppended = false; bool commaNeeded = false; foreach (KeyValuePair<string, object> valuePair in columns) { @@ -253,7 +277,16 @@ sqlBuilder.Add(Parameter.Placeholder); else sqlBuilder.Add((string) valuePair.Value); + assignmentsAppended = true; } + if (assignments != null) + { + if (assignmentsAppended) + { + sqlBuilder.Add(", "); + } + sqlBuilder.Add(assignments); + } sqlBuilder.Add(" WHERE "); bool andNeeded = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-05 18:07:11
|
Revision: 4246 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4246&view=rev Author: fabiomaulo Date: 2009-05-05 18:07:06 +0000 (Tue, 05 May 2009) Log Message: ----------- Continue port of AST tests for Updates Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -22,7 +22,7 @@ private readonly SqlString[] updates; private readonly IParameterSpecification[][] hqlParameters; - public MultiTableUpdateExecutor(IStatement statement, ILog log) : base(statement, log) + public MultiTableUpdateExecutor(IStatement statement) : base(statement, log) { if (!Factory.Dialect.SupportsTemporaryTables) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -11,6 +11,7 @@ using NHibernate.Persister.Entity; using NHibernate.SqlCommand; using NHibernate.Type; +using NHibernate.UserTypes; using NHibernate.Util; namespace NHibernate.Hql.Ast.ANTLR @@ -167,12 +168,69 @@ void PrepareVersioned(IASTNode updateNode, IASTNode versioned) { - throw new NotImplementedException(); // DML + var updateStatement = (UpdateStatement)updateNode; + FromClause fromClause = updateStatement.FromClause; + if (versioned != null) + { + // Make sure that the persister is versioned + IQueryable persister = fromClause.GetFromElement().Queryable; + if (!persister.IsVersioned) + { + throw new SemanticException("increment option specified for update of non-versioned entity"); + } + + IVersionType versionType = persister.VersionType; + if (versionType is IUserVersionType) + { + throw new SemanticException("user-defined version types not supported for increment option"); + } + + IASTNode eq = ASTFactory.CreateNode(EQ, "="); + IASTNode versionPropertyNode = GenerateVersionPropertyNode(persister); + + eq.SetFirstChild(versionPropertyNode); + + IASTNode versionIncrementNode; + if (typeof(DateTime).IsAssignableFrom(versionType.ReturnedClass)) + { + versionIncrementNode = ASTFactory.CreateNode(PARAM, "?"); + IParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification(versionType); + ((ParameterNode)versionIncrementNode).HqlParameterSpecification = paramSpec; + Parameters.Insert(0, paramSpec); + } + else + { + // Not possible to simply re-use the versionPropertyNode here as it causes + // OOM errors due to circularity :( + versionIncrementNode = ASTFactory.CreateNode(PLUS, "+"); + versionIncrementNode.SetFirstChild(GenerateVersionPropertyNode(persister)); + versionIncrementNode.AddChild(ASTFactory.CreateNode(IDENT, "1")); + } + + eq.AddChild(versionIncrementNode); + + EvaluateAssignment(eq, persister, 0); + + IASTNode setClause = updateStatement.SetClause; + IASTNode currentFirstSetElement = setClause.GetFirstChild(); + setClause.SetFirstChild(eq); + eq.NextSibling= currentFirstSetElement; + } } + private IASTNode GenerateVersionPropertyNode(IQueryable persister) + { + string versionPropertyName = persister.PropertyNames[persister.VersionProperty]; + var versionPropertyRef = ASTFactory.CreateNode(IDENT, versionPropertyName); + var versionPropertyNode = LookupNonQualifiedProperty(versionPropertyRef); + Resolve(versionPropertyNode); + return versionPropertyNode; + } + void PostProcessUpdate(IASTNode update) { - throw new NotImplementedException(); // DML + var updateStatement = (UpdateStatement)update; + PostProcessDML(updateStatement); } void PostProcessDelete(IASTNode delete) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -242,10 +242,12 @@ var list = new List<string>(); if (IsManipulationStatement) { - SqlString[] sqlStatements = statementExecutor.SqlStatements; - foreach (var sqlStatement in sqlStatements) + foreach (var sqlStatement in statementExecutor.SqlStatements) { - list.Add(sqlStatement.ToString()); + if (sqlStatement != null) + { + list.Add(sqlStatement.ToString()); + } } } else @@ -419,7 +421,7 @@ // even here, if only properties mapped to the "base table" are referenced // in the set and where clauses, this could be handled by the BasicDelegate. // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate - return new MultiTableDeleteExecutor(statement); + return new MultiTableUpdateExecutor(statement); } else { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -262,6 +262,24 @@ return null; } + set + { + if (_parent != null) + { + if (_parent.ChildCount > (ChildIndex + 1)) + { + _parent.SetChild(ChildIndex + 1, value); + } + else + { + AddSibling(value); + } + } + else + { + throw new InvalidOperationException("Trying set NextSibling without a parent."); + } + } } public IASTNode GetChild(int index) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IASTNode.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -15,7 +15,7 @@ int ChildCount { get; } int ChildIndex { get; } IASTNode Parent { get; set; } - IASTNode NextSibling { get; } + IASTNode NextSibling { get; set; } IASTNode GetChild(int index); IASTNode GetFirstChild(); void SetFirstChild(IASTNode newChild); Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-05 18:07:06 UTC (rev 4246) @@ -589,6 +589,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\JoinProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\LiteralProcessor.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> + <Compile Include="Param\VersionTypeSeedParameterSpecification.cs" /> <Compile Include="SqlCommand\InsertSelect.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> Added: trunk/nhibernate/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Param/VersionTypeSeedParameterSpecification.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -0,0 +1,36 @@ +using System.Data; +using NHibernate.Engine; +using NHibernate.Type; + +namespace NHibernate.Param +{ + public class VersionTypeSeedParameterSpecification : IParameterSpecification + { + private readonly IVersionType type; + + public VersionTypeSeedParameterSpecification(IVersionType type) + { + this.type = type; + } + + public int Bind(IDbCommand statement, QueryParameters qp, ISessionImplementor session, int position) + { + type.NullSafeSet(statement, type.Seed(session), position, session); + return 1; + } + + public IType ExpectedType + { + get { return type; } + set + { + // expected type is intrinsic here... + } + } + + public string RenderDisplayInfo() + { + return "version-seed, type=" + type; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-05 15:38:45 UTC (rev 4245) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-05 18:07:06 UTC (rev 4246) @@ -44,6 +44,81 @@ } } + [Test] + public void UpdateWithWhereExistsSubquery() + { + // multi-table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + var joe = new Human { Name = new Name { First = "Joe", Initial = 'Q', Last = "Public" } }; + s.Save(joe); + var doll = new Human {Name = new Name {First = "Kyu", Initial = 'P', Last = "Doll"}, Friends = new[] {joe}}; + s.Save(doll); + t.Commit(); + s.Close(); + + s = OpenSession(); + t = s.BeginTransaction(); + string updateQryString = "update Human h " + + "set h.description = 'updated' " + + "where exists (" + + " select f.id " + + " from h.friends f " + + " where f.name.last = 'Public' " + + ")"; + int count = s.CreateQuery(updateQryString).ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1)); + s.Delete(doll); + s.Delete(joe); + t.Commit(); + s.Close(); + + // single-table (one-to-many & many-to-many) ~~~~~~~~~~~~~~~~~~~~~~~~~~ + s = OpenSession(); + t = s.BeginTransaction(); + var entity = new SimpleEntityWithAssociation(); + var other = new SimpleEntityWithAssociation(); + entity.Name= "main"; + other.Name= "many-to-many-association"; + entity.ManyToManyAssociatedEntities.Add(other); + entity.AddAssociation("one-to-many-association"); + s.Save(entity); + t.Commit(); + s.Close(); + + s = OpenSession(); + t = s.BeginTransaction(); + // one-to-many test + updateQryString = "update SimpleEntityWithAssociation e " + + "set e.Name = 'updated' " + + "where exists (" + + " select a.id " + + " from e.AssociatedEntities a " + + " where a.Name = 'one-to-many-association' " + + ")"; + count = s.CreateQuery(updateQryString).ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1)); + // many-to-many test + if (Dialect.SupportsSubqueryOnMutatingTable) + { + updateQryString = "update SimpleEntityWithAssociation e " + + "set e.Name = 'updated' " + + "where exists (" + + " select a.id " + + " from e.ManyToManyAssociatedEntities a " + + " where a.Name = 'many-to-many-association' " + + ")"; + count = s.CreateQuery(updateQryString).ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1)); + } + var mtm = entity.ManyToManyAssociatedEntities.GetEnumerator(); + mtm.MoveNext(); + s.Delete(mtm.Current); + s.Delete(entity); + t.Commit(); + s.Close(); + } + #endregion #region DELETES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-05 22:37:56
|
Revision: 4247 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4247&view=rev Author: fabiomaulo Date: 2009-05-05 22:37:54 +0000 (Tue, 05 May 2009) Log Message: ----------- Continue port of AST tests for Updates (versioned entity) 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/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-05-05 18:07:06 UTC (rev 4246) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-05-05 22:37:54 UTC (rev 4247) @@ -1,4586 +1,4587 @@ -// $ANTLR 3.1.2 /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g 2009-04-23 21:03:14 - -// 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 EXPR_LIST = 73; - public const int EXISTS = 19; - public const int COMMA = 98; - public const int FETCH = 21; - public const int MINUS = 110; - public const int AS = 7; - public const int END = 56; - public const int INTO = 30; - public const int FALSE = 20; - public const int ELEMENTS = 17; - public const int THEN = 58; - public const int ALIAS = 70; - public const int ON = 60; - public const int DOT = 15; - public const int ORDER = 41; - public const int AND = 6; - public const int CONSTANT = 92; - public const int UNARY_MINUS = 88; - public const int METHOD_CALL = 79; - public const int RIGHT = 44; - public const int CONCAT = 108; - public const int PROPERTIES = 43; - public const int SELECT = 45; - public const int LE = 106; - public const int BETWEEN = 10; - public const int NUM_INT = 93; - public const int BOTH = 62; - public const int PLUS = 109; - public const int VERSIONED = 52; - public const int MEMBER = 65; - public const int UNION = 50; - public const int DISTINCT = 16; - public const int RANGE = 85; - public const int FILTER_ENTITY = 74; - public const int IDENT = 118; - public const int WHEN = 59; - public const int DESCENDING = 14; - public const int WS = 122; - public const int NEW = 37; - public const int EQ = 99; - public const int LT = 104; - public const int ESCqs = 121; - public const int OF = 67; - public const int UPDATE = 51; - public const int SELECT_FROM = 87; - public const int LITERAL_by = 54; - public const int FLOAT_SUFFIX = 124; - public const int ANY = 5; - public const int UNARY_PLUS = 89; - public const int NUM_FLOAT = 95; - public const int GE = 107; - public const int CASE = 55; - public const int OPEN_BRACKET = 113; - public const int ELSE = 57; - public const int OPEN = 100; - public const int COUNT = 12; - public const int NULL = 39; - public const int COLON = 115; - public const int DIV = 112; - public const int HAVING = 25; - public const int ALL = 4; - public const int SET = 46; - public const int INSERT = 29; - public const int TRUE = 49; - public const int CASE2 = 72; - public const int IS_NOT_NULL = 77; - public const int WHERE = 53; - public const int AGGREGATE = 69; - public const int VECTOR_EXPR = 90; - public const int LEADING = 64; - public const int CLOSE_BRACKET = 114; - public const int NUM_DOUBLE = 94; - public const int T__126 = 126; - public const int INNER = 28; - public const int QUERY = 84; - public const int ORDER_ELEMENT = 83; - public const int OR = 40; - public const int FULL = 23; - public const int INDICES = 27; - public const int IS_NULL = 78; - public const int GROUP = 24; - public const int ESCAPE = 18; - public const int T__127 = 127; - public const int PARAM = 116; - public const int ID_LETTER = 120; - public const int INDEX_OP = 76; - public const int HEX_DIGIT = 125; - public const int LEFT = 33; - public const int TRAILING = 68; - public const int JOIN = 32; - public const int NOT_BETWEEN = 80; - public const int SUM = 48; - public const int ROW_STAR = 86; - public const int OUTER = 42; - public const int NOT_IN = 81; - public const int FROM = 22; - public const int DELETE = 13; - public const int OBJECT = 66; - public const int MAX = 35; - public const int NOT_LIKE = 82; - public const int EMPTY = 63; - public const int QUOTED_String = 117; - public const int ASCENDING = 8; - public const int NUM_LONG = 96; - public const int IS = 31; - public const int SQL_NE = 103; - public const int IN_LIST = 75; - public const int WEIRD_IDENT = 91; - public const int NE = 102; - public const int GT = 105; - public const int MIN = 36; - public const int LIKE = 34; - public const int WITH = 61; - public const int IN = 26; - public const int CONSTRUCTOR = 71; - public const int SOME = 47; - public const int CLASS = 11; - public const int EXPONENT = 123; - public const int ID_START_LETTER = 119; - public const int EOF = -1; - public const int CLOSE = 101; - public const int AVG = 9; - public const int STAR = 111; - public const int NOT = 38; - public const int JAVA_CONSTANT = 97; - - // 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 "/Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:9:5: ( 'all' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:10:5: ( 'any' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:11:5: ( 'and' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:12:4: ( 'as' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:13:11: ( 'asc' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:14:5: ( 'avg' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:15:9: ( 'between' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:16:7: ( 'class' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:17:7: ( 'count' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:18:8: ( 'delete' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:19:12: ( 'desc' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:20:10: ( 'distinct' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:21:10: ( 'elements' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:22:8: ( 'escape' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:23:8: ( 'exists' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:24:7: ( 'false' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:25:7: ( 'fetch' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:26:6: ( 'from' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:27:6: ( 'full' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:28:7: ( 'group' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:29:8: ( 'having' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:30:4: ( 'in' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:31:9: ( 'indices' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:32:7: ( 'inner' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:33:8: ( 'insert' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:34:6: ( 'into' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:35:4: ( 'is' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:36:6: ( 'join' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:37:6: ( 'left' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:38:6: ( 'like' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:39:5: ( 'max' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:40:5: ( 'min' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:41:5: ( 'new' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:42:5: ( 'not' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:43:6: ( 'null' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:44:4: ( 'or' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:45:7: ( 'order' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:46:7: ( 'outer' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:47:12: ( 'properties' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:48:7: ( 'right' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:49:8: ( 'select' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:50:5: ( 'set' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:51:6: ( 'some' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:52:5: ( 'sum' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:53:6: ( 'true' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:54:7: ( 'union' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:55:8: ( 'update' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:56:11: ( 'versioned' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:57:7: ( 'where' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:58:12: ( 'by' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:59:6: ( 'case' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:60:5: ( 'end' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:61:6: ( 'else' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:62:6: ( 'then' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:63:6: ( 'when' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:64:4: ( 'on' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:65:6: ( 'with' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:66:6: ( 'both' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:67:7: ( 'empty' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:68:9: ( 'leading' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:69:8: ( 'member' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:70:8: ( 'object' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:71:4: ( 'of' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:72:10: ( 'trailing' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:73:8: ( 'ascending' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:74:8: ( 'descending' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:3: ( '=' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:742:3: ( '<' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:3: ( '>' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:744:7: ( '<>' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/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 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:745:5: '!=' - { - Match("!="); if (state.failed) return ; - - - } - break; - case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:746:3: ( '<=' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:747:3: ( '>=' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:749:6: ( ',' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:751:5: ( '(' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:752:6: ( ')' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:753:13: ( '[' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:754:14: ( ']' ) - // /Users/Steve/Projects/NHibernate/Trunk/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; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:756:7: ( '||' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:756:9: '||' - { - Match("||"); if (state.failed) r... [truncated message content] |
From: <fab...@us...> - 2009-05-06 06:12:23
|
Revision: 4249 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4249&view=rev Author: fabiomaulo Date: 2009-05-06 06:12:21 +0000 (Wed, 06 May 2009) Log Message: ----------- Continue port of AST tests for Updates (multitable entity) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-05 22:48:27 UTC (rev 4248) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableDeleteExecutor.cs 2009-05-06 06:12:21 UTC (rev 4249) @@ -82,20 +82,19 @@ { try { - var parameterTypes = new List<SqlType>(Walker.Parameters.Count); - foreach (var parameterSpecification in Walker.Parameters) + var paramsSpec = Walker.Parameters; + var parameterTypes = new List<SqlType>(paramsSpec.Count); + foreach (var parameterSpecification in paramsSpec) { parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); } ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, parameterTypes.ToArray()); - IEnumerator<IParameterSpecification> paramSpecifications = Walker.Parameters.GetEnumerator(); // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) int pos = 0; - while (paramSpecifications.MoveNext()) + foreach (var specification in paramsSpec) { - var paramSpec = paramSpecifications.Current; - pos += paramSpec.Bind(ps, parameters, session, pos); + pos += specification.Bind(ps, parameters, session, pos); } resultCount = session.Batcher.ExecuteNonQuery(ps); } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs 2009-05-05 22:48:27 UTC (rev 4248) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/MultiTableUpdateExecutor.cs 2009-05-06 06:12:21 UTC (rev 4249) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using log4net; using NHibernate.Engine; using NHibernate.Exceptions; @@ -16,7 +17,7 @@ [CLSCompliant(false)] public class MultiTableUpdateExecutor : AbstractStatementExecutor { - private static readonly ILog log = LogManager.GetLogger(typeof(MultiTableDeleteExecutor)); + private static readonly ILog log = LogManager.GetLogger(typeof (MultiTableDeleteExecutor)); private readonly IQueryable persister; private readonly SqlString idInsertSelect; private readonly SqlString[] updates; @@ -28,7 +29,7 @@ { throw new HibernateException("cannot perform multi-table updates using dialect not supporting temp tables"); } - var updateStatement = (UpdateStatement)statement; + var updateStatement = (UpdateStatement) statement; FromElement fromElement = updateStatement.FromClause.GetFromElement(); string bulkTargetAlias = fromElement.TableAlias; @@ -41,7 +42,7 @@ string[][] columnNames = persister.ContraintOrderedTableKeyColumnClosure; string idSubselect = GenerateIdSubselect(persister); - var assignmentSpecifications = Walker.AssignmentSpecifications; + IList<AssignmentSpecification> assignmentSpecifications = Walker.AssignmentSpecifications; updates = new SqlString[tableNames.Length]; hqlParameters = new IParameterSpecification[tableNames.Length][]; @@ -49,9 +50,10 @@ { bool affected = false; var parameterList = new List<IParameterSpecification>(); - SqlUpdateBuilder update = new SqlUpdateBuilder(Factory.Dialect, Factory) - .SetTableName(tableNames[tableIndex]) - .SetWhere("(" + StringHelper.Join(", ", columnNames[tableIndex]) + ") IN (" + idSubselect + ")"); + SqlUpdateBuilder update = + new SqlUpdateBuilder(Factory.Dialect, Factory).SetTableName(tableNames[tableIndex]) + .SetWhere( + string.Format("({0}) IN ({1})", StringHelper.Join(", ", columnNames[tableIndex]), idSubselect)); if (Factory.Settings.IsCommentsEnabled) { @@ -100,28 +102,16 @@ { try { - var parameterTypes = new List<SqlType>(Walker.Parameters.Count); - foreach (var parameterSpecification in Walker.Parameters) - { - parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); - } + int parameterStart = Walker.NumberOfParametersInSetClause; - ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, parameterTypes.ToArray()); + IList<IParameterSpecification> allParams = Walker.Parameters; - int parameterStart = Walker.NumberOfParametersInSetClause; + List<IParameterSpecification> whereParams = (new List<IParameterSpecification>(allParams)).GetRange( + parameterStart, allParams.Count - parameterStart); - var allParams = Walker.Parameters; + ps = session.Batcher.PrepareCommand(CommandType.Text, idInsertSelect, GetParametersTypes(whereParams)); - IEnumerator<IParameterSpecification> whereParams = - (new List<IParameterSpecification>(allParams)).GetRange(parameterStart, allParams.Count - parameterStart). - GetEnumerator(); - // NH Different behavior: The inital value is 0 (initialized to 1 in JAVA) - int pos = 0; - while (whereParams.MoveNext()) - { - var paramSpec = whereParams.Current; - pos += paramSpec.Bind(ps, parameters, session, pos); - } + BindParameters(whereParams, ps, parameters, session); resultCount = session.Batcher.ExecuteNonQuery(ps); } finally @@ -132,9 +122,10 @@ } } } - catch (System.Data.OleDb.OleDbException e) + catch (DbException e) { - throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not insert/select ids for bulk update", idInsertSelect); + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not insert/select ids for bulk update", + idInsertSelect); } // Start performing the updates @@ -148,16 +139,8 @@ { try { - ps = session.Batcher.PrepareCommand(CommandType.Text, updates[i], new SqlType[0]); - - if (hqlParameters[i] != null) - { - int position = 1; // ADO params are 0-based - for (int x = 0; x < hqlParameters[i].Length; x++) - { - position += hqlParameters[i][x].Bind(ps, parameters, session, position); - } - } + ps = session.Batcher.PrepareCommand(CommandType.Text, updates[i], GetParametersTypes(hqlParameters[i])); + BindParameters(hqlParameters[i], ps, parameters, session); session.Batcher.ExecuteNonQuery(ps); } finally @@ -168,7 +151,7 @@ } } } - catch (System.Data.OleDb.OleDbException e) + catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "error performing bulk update", updates[i]); } @@ -182,9 +165,37 @@ } } + private SqlType[] GetParametersTypes(IEnumerable<IParameterSpecification> specifications) + { + if (specifications == null) + { + return new SqlType[0]; + } + var result = new List<SqlType>(); + foreach (var specification in specifications) + { + result.AddRange(specification.ExpectedType.SqlTypes(Factory)); + } + return result.ToArray(); + } + + private static void BindParameters(IEnumerable<IParameterSpecification> specifications, IDbCommand command, + QueryParameters parameters, ISessionImplementor session) + { + if (specifications == null) + { + return; + } + int position = 0; // ADO params are 0-based + foreach (var specification in specifications) + { + position += specification.Bind(command, parameters, session, position); + } + } + protected override IQueryable[] AffectedQueryables { - get { return new[] { persister }; } + get { return new[] {persister}; } } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-05 22:48:27 UTC (rev 4248) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-06 06:12:21 UTC (rev 4249) @@ -166,8 +166,40 @@ s.Delete(entity); t.Commit(); s.Close(); - } - + } + + [Test] + public void UpdateOnComponent() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + var human = new Human {Name = new Name {First = "Stevee", Initial = 'X', Last = "Ebersole"}}; + + s.Save(human); + t.Commit(); + + string correctName = "Steve"; + + t = s.BeginTransaction(); + int count = + s.CreateQuery("update Human set name.first = :correction where id = :id") + .SetString("correction", correctName) + .SetInt64("id", human.Id).ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "incorrect update count"); + t.Commit(); + + t = s.BeginTransaction(); + s.Refresh(human); + + Assert.That(human.Name.First, Is.EqualTo(correctName), "Update did not execute properly"); + + s.CreateQuery("delete Human").ExecuteUpdate(); + t.Commit(); + + s.Close(); + } + #endregion #region DELETES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |