Inheritance: IErrorReporter
		public SqlString Generate()
		{
            if (_sql == null)
            {
                var gen = new SqlGenerator(_sfi, new CommonTreeNodeStream(_ast));

                try
                {
                    gen.statement();

                    _sql = gen.GetSQL();

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("SQL: " + _sql);
                    }
                }
                finally
                {
                    gen.ParseErrorHandler.ThrowQueryException();
                }

                _parameters = gen.GetCollectedParameters();
            }

		    return _sql;
		}
		private void HandleWithFragment(FromElement fromElement, IASTNode hqlWithNode)
		{
			try
			{
				ITreeNodeStream old = input;
				input = new CommonTreeNodeStream(adaptor, hqlWithNode);

				IASTNode hqlSqlWithNode = (IASTNode) withClause().Tree;
				input = old;

				if (log.IsDebugEnabled)
				{
					log.Debug("handleWithFragment() : " + _printer.ShowAsString(hqlSqlWithNode, "-- with clause --"));
				}
				WithClauseVisitor visitor = new WithClauseVisitor(fromElement);
				NodeTraverser traverser = new NodeTraverser(visitor);
				traverser.TraverseDepthFirst(hqlSqlWithNode);
				FromElement referencedFromElement = visitor.GetReferencedFromElement();
				if (referencedFromElement != fromElement)
				{
					throw new InvalidWithClauseException(
						"with-clause expressions did not reference from-clause element to which the with-clause was associated");
				}
				SqlGenerator sql = new SqlGenerator(_sessionFactoryHelper.Factory, new CommonTreeNodeStream(adaptor, hqlSqlWithNode.GetChild(0)));

				sql.whereExpr();

				var withClauseFragment = new SqlString("(", sql.GetSQL(), ")");
				fromElement.SetWithClauseFragment(visitor.GetJoinAlias(), withClauseFragment);
			}
			catch (SemanticException)
			{
				throw;
			}
			catch (InvalidWithClauseException)
			{
				throw;
			}
			catch (Exception e)
			{
				throw new SemanticException(e.Message);
			}
		}
Exemple #3
0
 internal DefaultWriter(SqlGenerator generator)
 {
     this.generator = generator;
 }
 internal DefaultWriter(SqlGenerator generator)
 {
     this.generator = generator;
 }