From: <ste...@us...> - 2009-05-13 16:09:03
|
Revision: 4290 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4290&view=rev Author: steverstrong Date: 2009-05-13 16:08:36 +0000 (Wed, 13 May 2009) Log Message: ----------- Cleaned up some code; a few renames, some reformatting, that sort of thing. No functional changes. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.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/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/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/JavaConstantNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.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/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -682,29 +682,9 @@ IASTNode CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch) { - // try - { - FromElement fromElement = _currentFromClause.AddFromElement(path, alias); - fromElement.SetAllPropertyFetch(propertyFetch != null); - return fromElement; - } - /* - catch (Exception e) - { - // Try resolving as if it were a join - // TODO - clean this up! - try - { - pathNode = PreProcessPathForJoin(pathNode); - - CreateFromJoinElement(pathNode, alias, INNER, null, null, null); - return null; - } - catch (Exception) - { - throw e; - } - }*/ + FromElement fromElement = _currentFromClause.AddFromElement(path, alias); + fromElement.SetAllPropertyFetch(propertyFetch != null); + return fromElement; } private IASTNode PreProcessPathForJoin(IASTNode node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -17,11 +17,11 @@ [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; + 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) { @@ -30,8 +30,8 @@ throw new QueryException("assignment in set-clause not associated with equals"); } - this.eq = eq; - factory = persister.Factory; + _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 @@ -63,30 +63,30 @@ { temp.Add(persister.GetSubclassTableName(persister.GetSubclassPropertyTableNumber(propertyPath))); } - tableNames = new ImmutableSet<string>(temp); + _tableNames = new ImmutableSet<string>(temp); if (rhs == null) { - hqlParameters = new IParameterSpecification[0]; + _hqlParameters = new IParameterSpecification[0]; } else if (IsParam(rhs)) { - hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; + _hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; } else { var parameterList = ASTUtil.CollectChildren(rhs, IsParam); - hqlParameters = new IParameterSpecification[parameterList.Count]; + _hqlParameters = new IParameterSpecification[parameterList.Count]; int i = 0; foreach (ParameterNode parameterNode in parameterList) { - hqlParameters[i++] = parameterNode.HqlParameterSpecification; + _hqlParameters[i++] = parameterNode.HqlParameterSpecification; } } } public bool AffectsTable(string tableName) { - return tableNames.Contains(tableName); + return _tableNames.Contains(tableName); } private static bool IsParam(IASTNode node) @@ -124,27 +124,27 @@ public IParameterSpecification[] Parameters { - get{return hqlParameters;} + get{return _hqlParameters;} } public SqlString SqlAssignmentFragment { get { - if (sqlAssignmentString == null) + if (_sqlAssignmentString == null) { try { - var gen = new SqlGenerator(factory, new CommonTreeNodeStream(eq)); + var gen = new SqlGenerator(_factory, new CommonTreeNodeStream(_eq)); gen.comparisonExpr(false); // false indicates to not generate parens around the assignment - sqlAssignmentString = gen.GetSQL(); + _sqlAssignmentString = gen.GetSQL(); } catch (Exception t) { throw new QueryException("cannot interpret set-clause assignment", t); } } - return sqlAssignmentString; + return _sqlAssignmentString; } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -12,7 +12,7 @@ [CLSCompliant(false)] public class BooleanLiteralNode : LiteralNode, IExpectedTypeAwareNode { - private IType expectedType; + private IType _expectedType; public BooleanLiteralNode(IToken token) : base(token) { @@ -22,7 +22,7 @@ { get { - return expectedType ?? NHibernateUtil.Boolean; + return _expectedType ?? NHibernateUtil.Boolean; } set { @@ -46,8 +46,8 @@ */ public IType ExpectedType { - get { return expectedType; } - set { expectedType = value; } + get { return _expectedType; } + set { _expectedType = value; } } public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -11,7 +11,7 @@ [CLSCompliant(false)] public class DeleteStatement : AbstractRestrictableStatement { - private static readonly ILog log = LogManager.GetLogger(typeof(DeleteStatement)); + private static readonly ILog Log = LogManager.GetLogger(typeof(DeleteStatement)); public DeleteStatement(IToken token) : base(token) {} @@ -27,7 +27,7 @@ protected override ILog GetLog() { - return log; + return Log; } protected override int GetWhereClauseParentTokenType() Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -20,18 +20,18 @@ [CLSCompliant(false)] public class DotNode : FromReferenceNode, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(DotNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(DotNode)); - private const int DEREF_UNKNOWN = 0; - private const int DEREF_ENTITY = 1; - private const int DEREF_COMPONENT = 2; - private const int DEREF_COLLECTION = 3; - private const int DEREF_PRIMITIVE = 4; - private const int DEREF_IDENTIFIER = 5; - private const int DEREF_JAVA_CONSTANT = 6; + private const int DerefUnknown = 0; + private const int DerefEntity = 1; + private const int DerefComponent = 2; + private const int DerefCollection = 3; + private const int DerefPrimitive = 4; + private const int DerefIdentifier = 5; + private const int DerefJavaConstant = 6; - public static bool UseThetaStyleImplicitJoins = false; - public static bool REGRESSION_STYLE_JOIN_SUPPRESSION = false; + public static bool UseThetaStyleImplicitJoins; + public static bool REGRESSION_STYLE_JOIN_SUPPRESSION; /// <summary> /// The full path, to the root alias of this dot node. @@ -41,7 +41,7 @@ /// <summary> /// The type of dereference that hapened (DEREF_xxx). /// </summary> - private int _dereferenceType = DEREF_UNKNOWN; + private int _dereferenceType = DerefUnknown; /// <summary> /// The identifier that is the name of the property. @@ -109,7 +109,7 @@ else { SqlNode rhs = (SqlNode) lhs.NextSibling; - _path = lhs.Path + "." + rhs.getOriginalText(); + _path = lhs.Path + "." + rhs.OriginalText; } } return _path; @@ -138,7 +138,7 @@ IType propertyType = PrepareLhs(); // Prepare the left hand side and get the data type. - DereferenceCollection( ( CollectionType ) propertyType, true, true, null, parent ); + DereferenceCollection( ( CollectionType ) propertyType, true, true, null); } public override void ResolveFirstChild() @@ -181,7 +181,7 @@ else { ResolveFirstChild(); - base.Resolve(generateJoin, implicitJoin); + Resolve(generateJoin, implicitJoin); } } @@ -226,7 +226,7 @@ { // The property is a collection... CheckLhsIsNotCollection(); - DereferenceCollection((CollectionType)propertyType, implicitJoin, false, classAlias, parent); + DereferenceCollection((CollectionType)propertyType, implicitJoin, false, classAlias); } else { @@ -235,13 +235,14 @@ { CheckLhsIsNotCollection(); } - _dereferenceType = DEREF_PRIMITIVE; + _dereferenceType = DerefPrimitive; InitText(); } IsResolved = true; } + public FromReferenceNode GetLhs() { FromReferenceNode lhs = ((FromReferenceNode)GetChild(0)); @@ -252,7 +253,7 @@ return lhs; } - public IType getDataType() + public IType GetDataType() { if (DataType == null) { @@ -265,20 +266,21 @@ // If the lhs is a collection, use CollectionPropertyMapping IType propertyType = fromElement.GetPropertyType(_propertyName, _propertyPath); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("getDataType() : " + _propertyPath + " -> " + propertyType); + Log.Debug("getDataType() : " + _propertyPath + " -> " + propertyType); } DataType = propertyType; } + return DataType; } public void SetResolvedConstant(string text) { _path = text; - _dereferenceType = DEREF_JAVA_CONSTANT; + _dereferenceType = DerefJavaConstant; IsResolved = true; // Don't resolve the node again. } @@ -288,13 +290,13 @@ return new QueryException("illegal attempt to dereference collection [" + lhsPath + "] with element property reference [" + propertyName + "]"); } - private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias, IASTNode parent) + private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias) { - _dereferenceType = DEREF_COLLECTION; + _dereferenceType = DerefCollection; string role = collectionType.Role; //foo.bars.size (also handles deprecated stuff like foo.bars.maxelement for backwardness) - IASTNode sibling = this.NextSibling; + IASTNode sibling = NextSibling; bool isSizeProperty = sibling != null && CollectionProperties.IsAnyCollectionProperty( sibling.Text ); if (isSizeProperty) @@ -330,9 +332,9 @@ ); FromElement elem = factory.CreateCollection( queryableCollection, role, _joinType, _fetch, indexed ); - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "dereferenceCollection() : Created new FROM element for " + propName + " : " + elem ); + Log.Debug( "dereferenceCollection() : Created new FROM element for " + propName + " : " + elem ); } SetImpliedJoin( elem ); @@ -422,9 +424,9 @@ { // special shortcut for id properties, skip the join! // this must only occur at the _end_ of a path expression - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("dereferenceShortcut() : property " + + Log.Debug("dereferenceShortcut() : property " + propertyName + " in " + FromElement.ClassName + " does not require a join."); } @@ -434,7 +436,7 @@ // Set the text for the parent. if (dotParent != null) { - dotParent._dereferenceType = DEREF_IDENTIFIER; + dotParent._dereferenceType = DerefIdentifier; dotParent.Text = Text; dotParent._columns = GetColumns(); } @@ -442,10 +444,10 @@ private void DereferenceEntityJoin(string classAlias, EntityType propertyType, bool impliedJoin, IASTNode parent) { - _dereferenceType = DEREF_ENTITY; - if ( log.IsDebugEnabled ) + _dereferenceType = DerefEntity; + if ( Log.IsDebugEnabled ) { - log.Debug( "dereferenceEntityJoin() : generating join for " + _propertyName + " in " + Log.Debug( "dereferenceEntityJoin() : generating join for " + _propertyName + " in " + FromElement.ClassName + " " + ( ( classAlias == null ) ? "{no alias}" : "(" + classAlias + ")" ) + " parent = " + ASTUtil.GetDebugstring( parent ) @@ -586,9 +588,9 @@ { if (IsCorrelatedSubselect) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug(methodName + "() : correlated subquery"); + Log.Debug(methodName + "() : correlated subquery"); } } } @@ -612,12 +614,12 @@ { FromReferenceNode lhs = GetLhs(); lhs.PrepareForDot( _propertyName ); - return getDataType(); + return GetDataType(); } private void DereferenceComponent(IASTNode parent) { - _dereferenceType = DEREF_COMPONENT; + _dereferenceType = DerefComponent; SetPropertyNameAndPath(parent); } @@ -631,16 +633,16 @@ _propertyName = rhs.Text; _propertyPath = _propertyPath + "." + _propertyName; // Append the new property name onto the unresolved path. dotNode._propertyPath = _propertyPath; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("Unresolved property path is now '" + dotNode._propertyPath + "'"); + Log.Debug("Unresolved property path is now '" + dotNode._propertyPath + "'"); } } else { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("terminal propertyPath = [" + _propertyPath + "]"); + Log.Debug("terminal propertyPath = [" + _propertyPath + "]"); } } } @@ -693,7 +695,7 @@ else { Resolve(true, false); - IType type = getDataType(); + IType type = GetDataType(); if (type.IsEntityType) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,10 +16,10 @@ [CLSCompliant(false)] public class FromClause : HqlSqlWalkerNode, IDisplayableNode { - private static readonly ILog log = LogManager.GetLogger(typeof(FromClause)); - public static int ROOT_LEVEL = 1; + private static readonly ILog Log = LogManager.GetLogger(typeof(FromClause)); + private const int RootLevel = 1; - private int _level = ROOT_LEVEL; + private int _level = RootLevel; /// <summary> /// Counts the from elements as they are added. @@ -124,9 +124,9 @@ public void AddJoinByPathMap(string path, FromElement destination) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("addJoinByPathMap() : " + path + " -> " + destination); + Log.Debug("addJoinByPathMap() : " + path + " -> " + destination); } _fromElementsByPath.Add(path, destination); @@ -134,9 +134,9 @@ public void AddCollectionJoinFromElementByPath(string path, FromElement destination) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("addCollectionJoinFromElementByPath() : " + path + " -> " + destination); + Log.Debug("addCollectionJoinFromElementByPath() : " + path + " -> " + destination); } _collectionJoinFromElementsByPath.Add(path, destination); // Add the new node to the map so that we don't create it twice. } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,7 +16,7 @@ [CLSCompliant(false)] public class FromElement : HqlSqlWalkerNode, IDisplayableNode, IParameterContainer { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElement)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElement)); private bool _isAllPropertyFetch; private FromElementType _elementType; @@ -27,17 +27,15 @@ private FromClause _fromClause; private string[] _columns; private FromElement _origin; - private bool _manyToMany; private bool _useFromFragment; private bool _useWhereFragment = true; private bool _includeSubclasses = true; - private List<FromElement> _destinations = new List<FromElement>(); + private readonly List<FromElement> _destinations = new List<FromElement>(); private bool _dereferencedBySubclassProperty; private bool _dereferencedBySuperclassProperty; private bool _collectionJoin; private string _role; - private int sequence = -1; - private bool initialized = false; + private bool _initialized; private string _withClauseFragment; private string _withClauseJoinAlias; private bool _filter; @@ -98,7 +96,7 @@ public bool Filter { - set { _filter = true; } + set { _filter = value; } } public bool IsFilter @@ -307,7 +305,7 @@ return _elementType.RenderPropertySelect(size, k, IsAllPropertyFetch); } - public override SqlString RenderText(NHibernate.Engine.ISessionFactoryImplementor sessionFactory) + public override SqlString RenderText(Engine.ISessionFactoryImplementor sessionFactory) { return SqlString.Parse(Text); } @@ -351,9 +349,9 @@ { if (IsDereferencedBySuperclassOrSubclassProperty) { - if (!_includeSubclasses && log.IsInfoEnabled) + if (!_includeSubclasses && Log.IsInfoEnabled) { - log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); + Log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); } } _includeSubclasses = value; @@ -485,9 +483,9 @@ { Declarer propertyDeclarer = persister.GetSubclassPropertyDeclarer(propertyName); - if (log.IsInfoEnabled) + if (Log.IsInfoEnabled) { - log.Info("handling property dereference [" + persister.EntityName + " (" + ClassAlias + ") -> " + propertyName + " (" + propertyDeclarer + ")]"); + Log.Info("handling property dereference [" + persister.EntityName + " (" + ClassAlias + ") -> " + propertyName + " (" + propertyDeclarer + ")]"); } if (propertyDeclarer == Declarer.SubClass) { @@ -511,7 +509,6 @@ public void SetOrigin(FromElement origin, bool manyToMany) { _origin = origin; - _manyToMany = manyToMany; origin.AddDestination(this); if (origin.FromClause == FromClause) @@ -551,9 +548,9 @@ { if (IsDereferencedBySuperclassOrSubclassProperty) { - if (!includeSubclasses && log.IsInfoEnabled) + if (!includeSubclasses && Log.IsInfoEnabled) { - log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); + Log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); } } _includeSubclasses = includeSubclasses; @@ -571,7 +568,7 @@ public void InitializeCollection(FromClause fromClause, string classAlias, string tableAlias) { DoInitialize(fromClause, tableAlias, null, classAlias, null, null); - initialized = true; + _initialized = true; } public void InitializeEntity(FromClause fromClause, @@ -582,13 +579,12 @@ string tableAlias) { DoInitialize(fromClause, tableAlias, className, classAlias, persister, type); - this.sequence = fromClause.NextFromElementCounter(); - initialized = true; + _initialized = true; } public void CheckInitialized() { - if (!initialized) + if (!_initialized) { throw new InvalidOperationException("FromElement has not been initialized!"); } @@ -632,7 +628,7 @@ private void DoInitialize(FromClause fromClause, string tableAlias, string className, string classAlias, IEntityPersister persister, EntityType type) { - if (initialized) + if (_initialized) { throw new InvalidOperationException("Already initialized!!"); } @@ -645,9 +641,9 @@ // Register the FromElement with the FROM clause, now that we have the names and aliases. fromClause.RegisterFromElement(this); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug(fromClause + " : " + className + " (" + Log.Debug(fromClause + " : " + className + " (" + (classAlias ?? "no alias") + ") -> " + tableAlias); } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -13,7 +13,7 @@ [CLSCompliant(false)] public class FromElementFactory { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElementFactory)); private readonly FromClause _fromClause; private readonly FromElement _origin; @@ -107,9 +107,9 @@ FromElement parentFromElement, string classAlias) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : path = " + path); + Log.Debug("createFromElementInSubselect() : path = " + path); } // Create an DotNode AST for the path and resolve it. @@ -119,23 +119,16 @@ // 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; - } + + string tableAlias = correlatedSubselect ? fromElement.TableAlias : null; // If the from element isn't in the same clause, create a new from element. if (fromElement.FromClause != _fromClause) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : creating a new FROM element..."); + Log.Debug("createFromElementInSubselect() : creating a new FROM element..."); } fromElement = CreateFromElement(entityPersister); @@ -148,9 +141,9 @@ tableAlias ); } - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); + Log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); } return fromElement; @@ -234,8 +227,6 @@ 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; @@ -249,21 +240,19 @@ _queryableCollection = queryableCollection; SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; - FromElement destination = null; - string tableAlias = null; IEntityPersister entityPersister = queryableCollection.ElementPersister; - tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); + string 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 - ); + FromElement 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) @@ -284,9 +273,8 @@ 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); + JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, JoinType.InnerJoin, targetColumns); + FromElement 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; @@ -310,9 +298,9 @@ // multi-table entity if (_implied && !elem.UseFromFragment) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createEntityJoin() : Implied entity join"); + Log.Debug("createEntityJoin() : Implied entity join"); } elem.UseFromFragment = true; } @@ -355,9 +343,9 @@ // Get the class name of the associated entity. if (_queryableCollection.IsOneToMany) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + Log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); } JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); @@ -366,9 +354,9 @@ } else { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + Log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); } elem = CreateManyToMany(role, associatedEntityName, @@ -491,7 +479,7 @@ { FromReferenceNode pathNode = (FromReferenceNode)PathHelper.ParsePath(path, _fromClause.ASTFactory); - pathNode.RecursiveResolve(FromReferenceNode.ROOT_LEVEL, // This is the root level node. + pathNode.RecursiveResolve(FromReferenceNode.RootLevel, // This is the root level node. false, // Generate an explicit from clause at the root. classAlias, null Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -19,11 +19,11 @@ [CLSCompliant(false)] public class FromElementType { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementType)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElementType)); - private FromElement _fromElement; - private IEntityPersister _persister; - private EntityType _entityType; + private readonly FromElement _fromElement; + private readonly IEntityPersister _persister; + private readonly EntityType _entityType; private IQueryableCollection _queryableCollection; private CollectionPropertyMapping _collectionPropertyMapping; private JoinSequence _joinSequence; @@ -170,7 +170,7 @@ public string RenderScalarIdentifierSelect(int i) { CheckInitialized(); - string[] cols = GetPropertyMapping(NHibernate.Persister.Entity.EntityPersister.EntityID).ToColumns(TableAlias, NHibernate.Persister.Entity.EntityPersister.EntityID); + string[] cols = GetPropertyMapping(Persister.Entity.EntityPersister.EntityID).ToColumns(TableAlias, Persister.Entity.EntityPersister.EntityID); StringBuilder buf = new StringBuilder(); // For property references generate <tablealias>.<columnname> as <projectionalias> for (int j = 0; j < cols.Length; j++) @@ -302,7 +302,7 @@ if (_queryableCollection.ElementType.IsComponentType) { // Collection of components. - if (propertyName == NHibernate.Persister.Entity.EntityPersister.EntityID) + if (propertyName == Persister.Entity.EntityPersister.EntityID) { return (IPropertyMapping)_queryableCollection.OwnerEntityPersister; } @@ -394,11 +394,11 @@ enabledFilters, propertyMapping.ToColumns(tableAlias, path) ); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("toColumns(" + tableAlias + "," + path + ") : subquery = " + subquery); + Log.Debug("toColumns(" + tableAlias + "," + path + ") : subquery = " + subquery); } - return new string[] { "(" + subquery + ")" }; + return new [] { "(" + subquery + ")" }; } else { @@ -429,15 +429,15 @@ // B) otherwise, we need to use the persister's // table name as the column qualification // 2) otherwise (not correlated), use the given alias - if (isCorrelation()) + if (IsCorrelation) { - if (isMultiTable()) + if (IsMultiTable) { return propertyMapping.ToColumns(tableAlias, path); } else { - return propertyMapping.ToColumns(extractTableName(), path); + return propertyMapping.ToColumns(ExtractTableName(), path); } } else @@ -448,7 +448,7 @@ else { string[] columns = propertyMapping.ToColumns(path); - log.Info("Using non-qualified column reference [" + path + " -> (" + ArrayHelper.ToString(columns) + ")]"); + Log.Info("Using non-qualified column reference [" + path + " -> (" + ArrayHelper.ToString(columns) + ")]"); return columns; } } @@ -470,21 +470,27 @@ _fromElement.CheckInitialized(); } - private bool isCorrelation() + private bool IsCorrelation { - FromClause top = _fromElement.Walker.GetFinalFromClause(); - return _fromElement.FromClause != _fromElement.Walker.CurrentFromClause && - _fromElement.FromClause == top; + get + { + FromClause top = _fromElement.Walker.GetFinalFromClause(); + return _fromElement.FromClause != _fromElement.Walker.CurrentFromClause && + _fromElement.FromClause == top; + } } - private bool isMultiTable() + private bool IsMultiTable { - // should be safe to only ever expect EntityPersister references here - return _fromElement.Queryable != null && - _fromElement.Queryable.IsMultiTable; + get + { + // should be safe to only ever expect EntityPersister references here + return _fromElement.Queryable != null && + _fromElement.Queryable.IsMultiTable; + } } - private string extractTableName() + private string ExtractTableName() { // should be safe to only ever expect EntityPersister references here return _fromElement.Queryable.TableName; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -8,9 +8,9 @@ [CLSCompliant(false)] public abstract class FromReferenceNode : AbstractSelectExpression, IResolvableNode, IDisplayableNode, IPathNode { - private static readonly ILog log = LogManager.GetLogger(typeof(FromReferenceNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromReferenceNode)); - public static int ROOT_LEVEL = 0; + public const int RootLevel = 0; private FromElement _fromElement; private bool _resolved; @@ -35,9 +35,9 @@ set { _resolved = true; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("Resolved : " + Path + " -> " + Text); + Log.Debug("Resolved : " + Path + " -> " + Text); } } } @@ -71,7 +71,7 @@ public virtual string Path { - get { return getOriginalText(); } + get { return OriginalText; } } public void RecursiveResolve(int level, bool impliedAtRoot, string classAlias, IASTNode parent) @@ -87,7 +87,7 @@ ResolveFirstChild(); bool impliedJoin = true; - if ( level == ROOT_LEVEL && !impliedAtRoot ) + if ( level == RootLevel && !impliedAtRoot ) { impliedJoin = false; } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -170,10 +170,8 @@ return dupped; } - else - { - throw new NotImplementedException(); - } + + throw new NotImplementedException(); } private void Initialise(object node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -61,33 +61,32 @@ // We are at the end return 0; } - else if (nodes[parentIndex + 1] != down) + + if (nodes[parentIndex + 1] != down) { // Next node is not a DOWN node, so we have no children return 0; } - else + + // Count the DOWNs & UPs + int downCount = 0; + int index = 1; + do { - // Count the DOWNs & UPs - int downCount = 0; - int index = 1; - do + if (nodes[parentIndex + index] == down) { - if (nodes[parentIndex + index] == down) - { - downCount++; - } - else if (nodes[parentIndex + index] == up) - { - downCount--; - } + downCount++; + } + else if (nodes[parentIndex + index] == up) + { + downCount--; + } - index++; - - } while (downCount > 0); + index++; + + } while (downCount > 0); - return index - 1; - } + return index - 1; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -189,10 +189,8 @@ return dupped; } - else - { - return base.DupNode(t); - } + + return base.DupNode(t); } void Initialise(object node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -14,10 +14,10 @@ [CLSCompliant(false)] public class IdentNode : FromReferenceNode, ISelectExpression { - private static int UNKNOWN = 0; - private static int PROPERTY_REF = 1; - private static int COMPONENT_REF = 2; - private bool _nakedPropertyRef = false; + private const int Unknown = 0; + private const int PropertyRef = 1; + private const int ComponentRef = 2; + private bool _nakedPropertyRef; public IdentNode(IToken token) : base(token) { @@ -81,7 +81,7 @@ throw new InvalidOperationException(); } - string propertyName = getOriginalText(); + string propertyName = OriginalText; if (!DataType.IsCollectionType) { throw new SemanticException("Collection expected; [" + propertyName + "] does not refer to a collection property"); @@ -92,21 +92,18 @@ string role = type.Role; IQueryableCollection queryableCollection = SessionFactoryHelper.RequireQueryableCollection(role); - string alias = null; // DotNode uses null here... string columnTableAlias = FromElement.TableAlias; - JoinType joinType = JoinType.InnerJoin; - bool fetch = false; FromElementFactory factory = new FromElementFactory( Walker.CurrentFromClause, FromElement, propertyName, - alias, + null, FromElement.ToColumns(columnTableAlias, propertyName, false), true ); - FromElement elem = factory.CreateCollection(queryableCollection, role, joinType, fetch, true); + FromElement elem = factory.CreateCollection(queryableCollection, role, JoinType.InnerJoin, false, true); FromElement = elem; Walker.AddQuerySpaces(queryableCollection.CollectionSpaces); // Always add the collection's query spaces. } @@ -128,7 +125,7 @@ DotNode dot = (DotNode)parent; if (parent.GetFirstChild() == this) { - if (ResolveAsNakedComponentPropertyRefLHS(dot)) + if (ResolveAsNakedComponentPropertyRefLhs(dot)) { // we are the LHS of the DOT representing a naked comp-prop-ref IsResolved = true; @@ -136,7 +133,7 @@ } else { - if (ResolveAsNakedComponentPropertyRefRHS(dot)) + if (ResolveAsNakedComponentPropertyRefRhs(dot)) { // we are the RHS of the DOT representing a naked comp-prop-ref IsResolved = true; @@ -146,12 +143,12 @@ else { int result = ResolveAsNakedPropertyRef(); - if (result == PROPERTY_REF) + if (result == PropertyRef) { // we represent a naked (simple) prop-ref IsResolved = true; } - else if (result == COMPONENT_REF) + else if (result == ComponentRef) { // EARLY EXIT!!! return so the resolve call explicitly coming from DotNode can // resolve this... @@ -184,25 +181,25 @@ if (fromElement == null) { - return UNKNOWN; + return Unknown; } IQueryable persister = fromElement.Queryable; if (persister == null) { - return UNKNOWN; + return Unknown; } IType propertyType = GetNakedPropertyType(fromElement); if (propertyType == null) { // assume this ident's text does *not* refer to a property on the given persister - return UNKNOWN; + return Unknown; } if ((propertyType.IsComponentType || propertyType.IsAssociationType)) { - return COMPONENT_REF; + return ComponentRef; } FromElement = fromElement; @@ -220,10 +217,10 @@ DataType = propertyType; _nakedPropertyRef = true; - return PROPERTY_REF; + return PropertyRef; } - private bool ResolveAsNakedComponentPropertyRefLHS(DotNode parent) + private bool ResolveAsNakedComponentPropertyRefLhs(DotNode parent) { FromElement fromElement = LocateSingleFromElement(); if (fromElement == null) @@ -235,15 +232,15 @@ if (componentType == null) { - throw new QueryException("Unable to resolve path [" + parent.Path + "], unexpected token [" + getOriginalText() + "]"); + throw new QueryException("Unable to resolve path [" + parent.Path + "], unexpected token [" + OriginalText + "]"); } if (!componentType.IsComponentType) { - throw new QueryException("Property '" + getOriginalText() + "' is not a component. Use an alias to reference associations or collections."); + throw new QueryException("Property '" + OriginalText + "' is not a component. Use an alias to reference associations or collections."); } IType propertyType ; // used to set the type of the parent dot node - string propertyPath = Text + "." + this.NextSibling.Text; + string propertyPath = Text + "." + NextSibling.Text; try { // check to see if our "propPath" actually @@ -263,7 +260,7 @@ return true; } - private bool ResolveAsNakedComponentPropertyRefRHS(DotNode parent) + private bool ResolveAsNakedComponentPropertyRefRhs(DotNode parent) { FromElement fromElement = LocateSingleFromElement(); if (fromElement == null) @@ -302,7 +299,7 @@ return null; } - string property = getOriginalText(); + string property = OriginalText; IType propertyType = null; try Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -7,8 +7,8 @@ [CLSCompliant(false)] public class ImpliedFromElement : FromElement { - private bool _impliedInFromClause = false; - private bool _inProjectionList = false; + private bool _impliedInFromClause; + private bool _inProjectionList; public ImpliedFromElement(IToken token) : base(token) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,9 +16,9 @@ { } - public IASTNode getInList() + public IASTNode InList { - return RightHandOperand; + get { return RightHandOperand; } } public override void Initialize() @@ -29,7 +29,7 @@ throw new SemanticException("left-hand operand of in operator was null"); } - IASTNode inList = getInList(); + IASTNode inList = InList; if (inList == null) { throw new SemanticException("right-hand operand of in operator was null"); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -19,7 +19,7 @@ [CLSCompliant(false)] public class IndexNode : FromReferenceNode { - private static readonly ILog log = LogManager.GetLogger(typeof(IndexNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(IndexNode)); public IndexNode(IToken token) : base(token) { @@ -49,7 +49,7 @@ IType type = collectionNode.DataType; if ( !type.IsCollectionType ) { - throw new SemanticException( "The [] operator cannot be applied to type " + type.ToString() ); + throw new SemanticException( "The [] operator cannot be applied to type " + type); } string collectionRole = ( ( CollectionType ) type ).Role; @@ -70,17 +70,17 @@ { FromElementFactory factory = new FromElementFactory( fromClause, fromElement, path ); elem = factory.CreateCollectionElementsJoin( queryableCollection, elementTable ); - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "No FROM element found for the elements of collection join path " + path + Log.Debug( "No FROM element found for the elements of collection join path " + path + ", created " + elem ); } } else { - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "FROM element found for collection join path " + path ); + Log.Debug( "FROM element found for collection join path " + path ); } } @@ -170,9 +170,9 @@ FromReferenceNode collectionNode = ( FromReferenceNode ) GetChild(0); String path = collectionNode.Path + "[]." + propertyName; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug( "Creating join for many-to-many elements for " + path ); + Log.Debug( "Creating join for many-to-many elements for " + path ); } FromElementFactory factory = new FromElementFactory( fromElement.FromClause, fromElement, path ); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -18,13 +18,13 @@ [CLSCompliant(false)] public class IntoClause : HqlSqlWalkerNode, IDisplayableNode { - private IQueryable persister; - private String columnSpec = string.Empty; - private IType[] types; + private IQueryable _persister; + private String _columnSpec = string.Empty; + private IType[] _types; - private bool discriminated; - private bool explicitIdInsertion; - private bool explicitVersionInsertion; + private bool _discriminated; + private bool _explicitIdInsertion; + private bool _explicitVersionInsertion; public IntoClause(IToken token) : base(token) @@ -38,13 +38,13 @@ throw new QueryException("cannot insert into abstract class (no table)"); } - this.persister = persister; + _persister = persister; InitializeColumns(); if (Walker.SessionFactoryHelper.HasPhysicalDiscriminatorColumn(persister)) { - discriminated = true; - columnSpec += ", " + persister.DiscriminatorColumnName; + _discriminated = true; + _columnSpec += ", " + persister.DiscriminatorColumnName; } ResetText(); @@ -52,53 +52,53 @@ private void ResetText() { - Text = "into " + TableName + " ( " + columnSpec + " )"; + Text = "into " + TableName + " ( " + _columnSpec + " )"; } public string TableName { - get { return persister.GetSubclassTableName(0); } + get { return _persister.GetSubclassTableName(0); } } public IQueryable Queryable { - get { return persister; } + get { return _persister; } } public string EntityName { - get { return persister.EntityName; } + get { return _persister.EntityName; } } public IType[] InsertionTypes { - get { return types; } + get { return _types; } } public bool IsDiscriminated { - get { return discriminated; } + get { return _discriminated; } } public bool IsExplicitIdInsertion { - get { return explicitIdInsertion; } + get { return _explicitIdInsertion; } } public bool IsExplicitVersionInsertion { - get { return explicitVersionInsertion; } + get { return _explicitVersionInsertion; } } public void PrependIdColumnSpec() { - columnSpec = persister.IdentifierColumnNames[0] + ", " + columnSpec; + _columnSpec = _persister.IdentifierColumnNames[0] + ", " + _columnSpec; ResetText(); } public void PrependVersionColumnSpec() { - columnSpec = persister.GetPropertyColumnNames(persister.VersionProperty)[0] + ", " + columnSpec; + _columnSpec = _persister.GetPropertyColumnNames(_persister.VersionProperty)[0] + ", " + _columnSpec; ResetText(); } @@ -106,17 +106,17 @@ { IType[] selectTypes = selectClause.QueryReturnTypes; - if (selectTypes.Length != types.Length) + if (selectTypes.Length != _types.Length) { throw new QueryException("number of select types did not match those for insert"); } - for (int i = 0; i < types.Length; i++) + for (int i = 0; i < _types.Length; i++) { - if (!AreCompatible(types[i], selectTypes[i])) + if (!AreCompatible(_types[i], selectTypes[i])) { throw new QueryException( - "insertion type [" + types[i] + "] and selection type [" + + "insertion type [" + _types[i] + "] and selection type [" + selectTypes[i] + "] at position " + i + " are not compatible" ); } @@ -135,7 +135,7 @@ buf.Append("IntoClause{"); buf.Append("entityName=").Append(EntityName); buf.Append(",tableName=").Append(TableName); - buf.Append(",columns={").Append(columnSpec).Append("}"); + buf.Append(",columns={").Append(_columnSpec).Append("}"); buf.Append("}"); return buf.ToString(); } @@ -145,8 +145,8 @@ IASTNode propertySpec = GetFirstChild(); var ts = new List<IType>(); VisitPropertySpecNodes(propertySpec.GetFirstChild(), ts); - types = ts.ToArray(); - columnSpec = columnSpec.Substring(0, columnSpec.Length - 2); + _types = ts.ToArray(); + _columnSpec = _columnSpec.Substring(0, _columnSpec.Length - 2); } private void VisitPropertySpecNodes(IASTNode propertyNode, ICollection<IType> types) @@ -171,22 +171,22 @@ throw new QueryException("INSERT statements cannot refer to superclass/joined properties [" + name + "]"); } - if (name == persister.IdentifierPropertyName) + if (name == _persister.IdentifierPropertyName) { - explicitIdInsertion = true; + _explicitIdInsertion = true; } - if (persister.IsVersioned) + if (_persister.IsVersioned) { - if (name == persister.PropertyNames[persister.VersionProperty]) + if (name == _persister.PropertyNames[_persister.VersionProperty]) { - explicitVersionInsertion = true; + _explicitVersionInsertion = true; } } - string[] columnNames = persister.ToColumns(name); + string[] columnNames = _persister.ToColumns(name); RenderColumns(columnNames); - types.Add(persister.ToType(name)); + types.Add(_persister.ToType(name)); // visit width-first, then depth VisitPropertySpecNodes(propertyNode.NextSibling, types); @@ -197,7 +197,7 @@ { for (int i = 0; i < columnNames.Length; i++) { - columnSpec += columnNames[i] + ", "; + _columnSpec += columnNames[i] + ", "; } } @@ -214,7 +214,7 @@ // // we may want to disallow it for discrim-subclass just for // consistency-sake (currently does not work anyway)... - return persister.GetSubclassPropertyTableNumber(propertyName) != 0; + return _persister.GetSubclassPropertyTableNumber(propertyName) != 0; } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -1,5 +1,4 @@ using System; -using System.Threading; using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Util; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,7 +16,7 @@ [CLSCompliant(false)] public class MethodNode : AbstractSelectExpression, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(MethodNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(MethodNode)); private string[] _selectColumns; private string _methodName; @@ -151,15 +151,15 @@ SqlNode expr = ( SqlNode ) path; IType type = expr.DataType; - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "collectionProperty() : name=" + name + " type=" + type ); + Log.Debug( "collectionProperty() : name=" + name + " type=" + type ); } ResolveCollectionProperty( expr ); } - private void PrepareAnyImplicitJoins(DotNode dotNode) + private static void PrepareAnyImplicitJoins(DotNode dotNode) { if ( dotNode.GetLhs() is DotNode ) { @@ -181,7 +181,7 @@ IQueryableCollection queryableCollection = collectionFromElement.QueryableCollection; String path = collectionNode.Path + "[]." + propertyName; - log.Debug("Creating elements for " + path); + Log.Debug("Creating elements for " + path); _fromElement = collectionFromElement; if (!collectionFromElement.IsCollectionOfValuesOrComponents) @@ -203,14 +203,7 @@ if (exprList != null) { - if (_methodName == "iif") - { - child = exprList.GetChild(1); - } - else - { - child = exprList.GetChild(0); - } + child = _methodName == "iif" ? exprList.GetChild(1) : exprList.GetChild(0); } DataType = SessionFactoryHelper.FindFunctionReturnType(_methodName, child); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -1,5 +1,4 @@ using System; -using System.Text; using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Param; @@ -49,7 +48,7 @@ public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) { - int count = 0; + int count; if (ExpectedType != null && (count = ExpectedType.GetColumnSpan(sessionFactory)) > 1) { SqlStringBuilder buffer = new SqlStringBuilder(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -9,7 +9,7 @@ [CLSCompliant(false)] public class QueryNode : AbstractRestrictableStatement, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(QueryNode)); private OrderByClause _orderByClause; @@ -19,7 +19,7 @@ protected override ILog GetLog() { - return log; + return Log; } protected override int GetWhereClauseParentTokenType() @@ -89,17 +89,13 @@ // if there is no order by, make one if (_orderByClause == null) { - log.Debug( "getOrderByClause() : Creating a new ORDER BY clause" ); + Log.Debug( "getOrderByClause() : Creating a new ORDER BY clause" ); _orderByClause = (OrderByClause) Walker.ASTFactory.CreateNode(HqlSqlWalker.ORDER, "ORDER"); // Find the WHERE; if there is no WHERE, find the FROM... - IASTNode prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.WHERE); + IASTNode prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.WHERE) ?? + ASTUtil.FindTypeInChildren(this, HqlSqlWalker.FROM); - if ( prevSibling == null ) - { - prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.FROM); - } - // Now, inject the newly built ORDER BY into the tree prevSibling.AddSibling(_orderByClause); } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -25,7 +25,7 @@ private ConstructorNode _constructorNode; private string[] _aliases; - public static bool VERSION2_SQL = false; + public static bool VERSION2_SQL; public SelectClause(IToken token) : base(token) { @@ -179,7 +179,7 @@ if ( fromElement.IsFetch ) { FromElement origin; - if ( fromElement.RealOrigin == null ) + if ( fromElement.RealOrigin == null ) { // work around that crazy issue where the tree contains // "empty" FromElements (no text); afaict, this is caused @@ -188,10 +188,8 @@ { throw new QueryException( "Unable to determine origin of join fetch [" + fromElement.GetDisplayText() + "]" ); } - else - { - origin = fromElement.Origin; - } + + origin = fromElement.Origin; ... [truncated message content] |