private void PostProcessDML(IRestrictableStatement statement)
        {
            statement.FromClause.Resolve();

            var        fromElement = statement.FromClause.GetFromElementsTyped()[0];
            IQueryable persister   = fromElement.Queryable;

            // Make #@%$^#^&# sure no alias is applied to the table name
            fromElement.Text = persister.TableName;

            // Use the same logic as query does in order to support session filters
            var joinProcessor = new JoinProcessor(this);

            joinProcessor.ProcessJoins(statement);
        }
        void ProcessQuery(IASTNode select, IASTNode query)
        {
            if (log.IsDebugEnabled())
            {
                log.Debug("processQuery() : {0}", query.ToStringTree());
            }

            try {
                QueryNode qn = ( QueryNode )query;

                // Was there an explicit select expression?
                bool explicitSelect = select != null && select.ChildCount > 0;

                if (!explicitSelect)
                {
                    // No explicit select expression; render the id and properties
                    // projection lists for every persister in the from clause into
                    // a single 'token node'.
                    //TODO: the only reason we need this stuff now is collection filters,
                    //      we should get rid of derived select clause completely!
                    CreateSelectClauseFromFromClause(qn);
                }
                else
                {
                    // Use the explicitly declared select expression; determine the
                    // return types indicated by each select token
                    UseSelectClause(select);
                }

                // After that, process the JOINs.
                // Invoke a delegate to do the work, as this is farily complex.
                JoinProcessor joinProcessor = new JoinProcessor(this);
                joinProcessor.ProcessJoins(qn);

                // Attach any mapping-defined "ORDER BY" fragments
                foreach (FromElement fromElement in qn.FromClause.GetProjectionList())
                {
                    if (fromElement.IsFetch && fromElement.QueryableCollection != null)
                    {
                        // Does the collection referenced by this FromElement
                        // specify an order-by attribute?  If so, attach it to
                        // the query's order-by
                        if (fromElement.QueryableCollection.HasOrdering)
                        {
                            string orderByFragment = fromElement
                                                     .QueryableCollection
                                                     .GetSQLOrderByString(fromElement.TableAlias);
                            qn.GetOrderByClause().AddOrderFragment(orderByFragment);
                        }
                        if (fromElement.QueryableCollection.HasManyToManyOrdering)
                        {
                            string orderByFragment = fromElement.QueryableCollection
                                                     .GetManyToManyOrderByString(fromElement.TableAlias);
                            qn.GetOrderByClause().AddOrderFragment(orderByFragment);
                        }
                    }
                }
            }
            finally
            {
                PopFromClause();
            }
        }