Ejemplo n.º 1
0
        IASTNode CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch)
        {
            FromElement fromElement = _currentFromClause.AddFromElement(path, alias);

            fromElement.SetAllPropertyFetch(propertyFetch != null);
            return(fromElement);
        }
Ejemplo n.º 2
0
        void CreateFromJoinElement(
            IASTNode path,
            IASTNode alias,
            int joinType,
            IASTNode fetchNode,
            IASTNode propertyFetch,
            IASTNode with)
        {
            bool fetch = fetchNode != null;

            if (fetch && IsSubQuery)
            {
                throw new QueryException("fetch not allowed in subquery from-elements");
            }
            // The path AST should be a DotNode, and it should have been evaluated already.
            if (path.Type != DOT)
            {
                throw new SemanticException("Path expected for join!");
            }

            DotNode dot = ( DotNode )path;
            //JoinType hibernateJoinType = JoinProcessor.ToHibernateJoinType( joinType );
            JoinType hibernateJoinType = _impliedJoinType;

            dot.JoinType = hibernateJoinType;                   // Tell the dot node about the join type.
            dot.Fetch    = fetch;

            // Generate an explicit join for the root dot node.   The implied joins will be collected and passed up
            // to the root dot node.
            dot.Resolve(true, false, alias == null ? null : alias.Text);

            FromElement fromElement = dot.GetImpliedJoin();

            if (fromElement == null)
            {
                throw new InvalidPathException("Invalid join: " + dot.Path);
            }

            fromElement.SetAllPropertyFetch(propertyFetch != null);

            if (with != null)
            {
                if (fetch)
                {
                    throw new SemanticException("with-clause not allowed on fetched associations; use filters");
                }

                HandleWithFragment(fromElement, with);
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("createFromJoinElement() : " + _printer.ShowAsString(fromElement, "-- join tree --"));
            }
        }
Ejemplo n.º 3
0
        static void SetPropertyFetch(FromElement fromElement, IASTNode propertyFetch, IASTNode alias)
        {
            if (propertyFetch == null)
            {
                return;
            }

            if (propertyFetch.ChildCount == 0)
            {
                fromElement.SetAllPropertyFetch(true);
            }
            else
            {
                var propertyPaths = new string[propertyFetch.ChildCount / 2];
                for (var i = 1; i < propertyFetch.ChildCount; i = i + 2)
                {
                    string propertyPath;
                    var    child = propertyFetch.GetChild(i);

                    // o.PropName
                    if (child is DotNode dotNode)
                    {
                        dotNode.JoinType     = JoinType.None;
                        dotNode.PropertyPath = GetPropertyPath(dotNode, alias);
                        propertyPath         = dotNode.PropertyPath;
                    }
                    else if (child is IdentNode identNode)
                    {
                        propertyPath = identNode.OriginalText;
                    }
                    else
                    {
                        throw new InvalidOperationException($"Unable to determine property path for AST node: {child.ToStringTree()}");
                    }

                    propertyPaths[(i - 1) / 2] = propertyPath;
                }

                fromElement.FetchLazyProperties = propertyPaths;
            }
        }