/// <summary>
		/// Performs both filter and non-filter compiling.
		/// </summary>
		/// <param name="replacements">Defined query substitutions.</param>
		/// <param name="shallow">Does this represent a shallow (scalar or entity-id) select?</param>
		/// <param name="collectionRole">the role name of the collection used as the basis for the filter, NULL if this is not a filter.</param>
		private void DoCompile(IDictionary<string, string> replacements, bool shallow, String collectionRole) 
		{
			// If the query is already compiled, skip the compilation.
			if ( _compiled ) 
			{
				if ( log.IsDebugEnabled ) 
				{
					log.Debug( "compile() : The query is already compiled, skipping..." );
				}
				return;
			}

			// Remember the parameters for the compilation.
			_tokenReplacements = replacements ?? new Dictionary<string, string>(1);

			_shallowQuery = shallow;

			try 
			{
			    // PHASE 1 : Analyze the HQL AST, and produce an SQL AST.
				var translator = Analyze(collectionRole);

				_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
				// command executions.
				//
				// Possible to just move the sql generation for dml stuff, but for
				// consistency-sake probably best to just move responsiblity for
				// the generation phase completely into the delegates
				// (QueryLoader/StatementExecutor) themselves.  Also, not sure why
				// 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 (_sqlAst.NeedsExecutor) 
				{
					_statementExecutor = BuildAppropriateStatementExecutor(_sqlAst);
				}
				else 
				{
					// PHASE 2 : Generate the SQL.
					_generator = new HqlSqlGenerator(_sqlAst, _factory);
					_generator.Generate();

					_queryLoader = new QueryLoader(this, _factory, _sqlAst.Walker.SelectClause);
				}

				_compiled = true;
			}
			catch ( QueryException qe ) 
			{
				qe.QueryString = _queryIdentifier;
				throw;
			}
			catch ( RecognitionException e ) 
			{
				// we do not actually propogate ANTLRExceptions as a cause, so
				// log it here for diagnostic purposes
				if ( log.IsInfoEnabled ) 
				{
					log.Info( "converted antlr.RecognitionException", e );
				}
                throw QuerySyntaxException.Convert(e, _queryIdentifier);
			}

			_enabledFilters = null; //only needed during compilation phase...
		}
        /// <summary>
        /// Performs both filter and non-filter compiling.
        /// </summary>
        /// <param name="replacements">Defined query substitutions.</param>
        /// <param name="shallow">Does this represent a shallow (scalar or entity-id) select?</param>
        /// <param name="collectionRole">the role name of the collection used as the basis for the filter, NULL if this is not a filter.</param>
        private void DoCompile(IDictionary <string, string> replacements, bool shallow, String collectionRole)
        {
            // If the query is already compiled, skip the compilation.
            if (_compiled)
            {
                if (log.IsDebugEnabled())
                {
                    log.Debug("compile() : The query is already compiled, skipping...");
                }
                return;
            }

            // Remember the parameters for the compilation.
            _tokenReplacements = replacements ?? new Dictionary <string, string>(1);

            _shallowQuery = shallow;

            try
            {
                // PHASE 1 : Analyze the HQL AST, and produce an SQL AST.
                var translator = Analyze(collectionRole);

                _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
                // command executions.
                //
                // Possible to just move the sql generation for dml stuff, but for
                // consistency-sake probably best to just move responsiblity for
                // the generation phase completely into the delegates
                // (QueryLoader/StatementExecutor) themselves.  Also, not sure why
                // 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 (_sqlAst.NeedsExecutor)
                {
                    _statementExecutor = BuildAppropriateStatementExecutor(_sqlAst);
                }
                else
                {
                    // PHASE 2 : Generate the SQL.
                    _generator = new HqlSqlGenerator(_sqlAst, _factory);
                    _generator.Generate();

                    _queryLoader = new QueryLoader(this, _factory, _sqlAst.Walker.SelectClause);
                }

                _compiled = true;
            }
            catch (QueryException qe)
            {
                qe.QueryString = _queryIdentifier;
                throw;
            }
            catch (RecognitionException e)
            {
                // we do not actually propogate ANTLRExceptions as a cause, so
                // log it here for diagnostic purposes
                if (log.IsInfoEnabled())
                {
                    log.Info(e, "converted antlr.RecognitionException");
                }
                throw QuerySyntaxException.Convert(e, _queryIdentifier);
            }

            _enabledFilters = null;             //only needed during compilation phase...
        }
 public ExecuteQuerySqlStatement(IStatementExecutor commandExecutor, IEntityMapper entityMapper)
     : base(commandExecutor)
 {
     this.entityMapper = entityMapper;
 }
 public SelectStatement(IStatementExecutor statementExecutor, IEntityMapper entityMapper)
     : base(statementExecutor, entityMapper)
 {
     this.InitialiseConfig();
 }
Esempio n. 5
0
 public ExecuteNonQueryProcedureStatement(IStatementExecutor statementExecutor)
     : base(statementExecutor)
 {
 }
Esempio n. 6
0
 public ExecuteNonQuerySqlStatement(IStatementExecutor statementExecutor)
     : base(statementExecutor)
 {
 }
 protected ExecuteSqlStatement(IStatementExecutor statementExecutor)
 {
     StatementExecutor = statementExecutor;
 }
 public UpdateStatementBase(IStatementExecutor statementExecutor, IEntityMapper entityMapper, IWritablePropertyMatcher writablePropertyMatcher, IWhereClauseBuilder whereClauseBuilder)
     : base(statementExecutor, entityMapper, writablePropertyMatcher)
 {
     this.writablePropertyMatcher = writablePropertyMatcher;
     this.whereClauseBuilder      = whereClauseBuilder;
 }