public IStatement Translate() { if (_resultAst == null) { if (_collectionRole != null) { HqlFilterPreprocessor.AddImpliedFromToQuery(_inputAst, _collectionRole, _sfi); } var nodes = new BufferedTreeNodeStream(_inputAst); var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement)hqlSqlWalker.statement().Tree; } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return(_resultAst); }
public IStatement Translate() { if (_resultAst == null) { var nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); nodes.TokenStream = _tokens; var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement)hqlSqlWalker.statement().Tree; /* * if ( AST_LOG.isDebugEnabled() ) { * ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); * AST_LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); * } */ } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return(_resultAst); }
private static IStatementExecutor BuildAppropriateStatementExecutor(IStatement statement) { HqlSqlWalker walker = statement.Walker; if (walker.StatementType == HqlSqlWalker.DELETE) { FromElement fromElement = walker.GetFinalFromClause().GetFromElement(); IQueryable persister = fromElement.Queryable; if (persister.IsMultiTable) { return(new MultiTableDeleteExecutor(statement)); } else { return(new BasicExecutor(statement, 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 return(new MultiTableUpdateExecutor(statement)); } else { return(new BasicExecutor(statement, persister)); } } else if (walker.StatementType == HqlSqlWalker.INSERT) { return(new BasicExecutor(statement, ((InsertStatement)statement).IntoClause.Queryable)); } else { throw new QueryException("Unexpected statement type"); } }
public IStatement Translate() { if (_resultAst == null) { var nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement)hqlSqlWalker.statement().Tree; } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return(_resultAst); }
public IStatement Translate() { if (_resultAst == null) { var nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement) hqlSqlWalker.statement().Tree; } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return _resultAst; }
public IStatement Translate() { if (_resultAst == null) { if (_collectionRole != null) { HqlFilterPreprocessor.AddImpliedFromToQuery(_inputAst, _collectionRole, _sfi); } var nodes = new BufferedTreeNodeStream(_inputAst); var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement) hqlSqlWalker.statement().Tree; } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return _resultAst; }
public IStatement Translate() { if (_resultAst == null) { var nodes = new HqlSqlWalkerTreeNodeStream(_inputAst); nodes.TokenStream = _tokens; var hqlSqlWalker = new HqlSqlWalker(_qti, _sfi, nodes, _tokenReplacements, _collectionRole); hqlSqlWalker.TreeAdaptor = new HqlSqlWalkerTreeAdaptor(hqlSqlWalker); try { // Transform the tree. _resultAst = (IStatement) hqlSqlWalker.statement().Tree; /* if ( AST_LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); AST_LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); } */ } finally { hqlSqlWalker.ParseErrorHandler.ThrowQueryException(); } } return _resultAst; }