Пример #1
0
        public static ExpressionToHqlTranslationResults GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, bool root)
        {
            // Remove unnecessary body operators
            RemoveUnnecessaryBodyOperators.ReWrite(queryModel);

            // Merge aggregating result operators (distinct, count, sum etc) into the select clause
            MergeAggregatingResultsRewriter.ReWrite(queryModel);

            // Rewrite aggregate group-by statements
            AggregatingGroupByRewriter.ReWrite(queryModel);

            // Swap out non-aggregating group-bys
            NonAggregatingGroupByRewriter.ReWrite(queryModel);

            // Rewrite aggregating group-joins
            AggregatingGroupJoinRewriter.ReWrite(queryModel);

            // Rewrite non-aggregating group-joins
            NonAggregatingGroupJoinRewriter.ReWrite(queryModel);

            // Flatten pointless subqueries
            QueryReferenceExpressionFlattener.ReWrite(queryModel);

            // Add left joins for references
            AddLeftJoinsReWriter.ReWrite(queryModel, parameters.SessionFactory);

            var visitor = new QueryModelVisitor(parameters, root, queryModel);

            visitor.Visit();

            return(visitor._hqlTree.GetTranslation());
        }
Пример #2
0
        public static ExpressionToHqlTranslationResults GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, bool root)
        {
            // Remove unnecessary body operators
            RemoveUnnecessaryBodyOperators.ReWrite(queryModel);

            // Merge aggregating result operators (distinct, count, sum etc) into the select clause
            MergeAggregatingResultsRewriter.ReWrite(queryModel);

            // Rewrite aggregate group-by statements
            AggregatingGroupByRewriter.ReWrite(queryModel);

            // Swap out non-aggregating group-bys
            NonAggregatingGroupByRewriter.ReWrite(queryModel);

            // Rewrite aggregating group-joins
            AggregatingGroupJoinRewriter.ReWrite(queryModel);

            // Rewrite non-aggregating group-joins
            NonAggregatingGroupJoinRewriter.ReWrite(queryModel);

            // Flatten pointless subqueries
            QueryReferenceExpressionFlattener.ReWrite(queryModel);

            // Add left joins for references
            AddLeftJoinsReWriter.ReWrite(queryModel, parameters.SessionFactory);

            // Move OrderBy clauses to end
            MoveOrderByToEndRewriter.ReWrite(queryModel);

            // rewrite any operators that should be applied on the outer query
            // by flattening out the sub-queries that they are located in
            ResultOperatorRewriterResult result = ResultOperatorRewriter.Rewrite(queryModel);

            QueryModelVisitor visitor = new QueryModelVisitor(parameters, root, queryModel)
            {
                RewrittenOperatorResult = result
            };

            visitor.Visit();

            return(visitor._hqlTree.GetTranslation());
        }
Пример #3
0
        public static void ReWrite(QueryModel queryModel, ISessionFactory sessionFactory)
        {
            var rewriter = new AddLeftJoinsReWriter(sessionFactory);

            rewriter.VisitQueryModel(queryModel);
        }
Пример #4
0
        public static void ReWrite(QueryModel queryModel, ISessionFactory sessionFactory)
        {
            var rewriter = new AddLeftJoinsReWriter(sessionFactory);

            rewriter.VisitQueryModel(queryModel);
        }