Esempio n. 1
0
        public FromElement CreateEntityJoin(
            string entityClass,
            string tableAlias,
            JoinSequence joinSequence,
            bool fetchFlag,
            bool inFrom,
            EntityType type)
        {
            FromElement elem = CreateJoin(entityClass, tableAlias, joinSequence, type, false);

            elem.Fetch = fetchFlag;

            //if (numberOfTables > 1 && _implied && !elem.UseFromFragment)
            // NH Different behavior: numberOfTables was removed because an
            // implicit join is an implicit join even if it not come from a
            // multi-table entity
            if (_implied && !elem.UseFromFragment)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug("createEntityJoin() : Implied entity join");
                }
                elem.UseFromFragment = true;
            }

            // If this is an implied join in a FROM clause, then use ANSI-style joining, and set the
            // flag on the FromElement that indicates that it was implied in the FROM clause itself.
            if (_implied && inFrom)
            {
                joinSequence.SetUseThetaStyle(false);
                elem.UseFromFragment = true;
                elem.SetImpliedInFromClause(true);
            }
            if (elem.Walker.IsSubQuery)
            {
                // two conditions where we need to transform this to a theta-join syntax:
                //      1) 'elem' is the "root from-element" in correlated subqueries
                //      2) The DotNode.useThetaStyleImplicitJoins has been set to true
                //          and 'elem' represents an implicit join
                if (elem.FromClause != elem.Origin.FromClause || DotNode.UseThetaStyleImplicitJoins)
                {
                    // the "root from-element" in correlated subqueries do need this piece
                    elem.Type = HqlSqlWalker.FROM_FRAGMENT;
                    joinSequence.SetUseThetaStyle(true);
                    elem.UseFromFragment = false;
                }
            }

            return(elem);
        }