Package org.apache.cayenne.query

Examples of org.apache.cayenne.query.PrefetchTreeNode


            // a joint prefetch warrants full row compare

            final boolean[] compareFullRows = new boolean[1];

            QueryMetadata md = query.getMetaData(getEntityResolver());
            final PrefetchTreeNode rootPrefetch = md.getPrefetchTree();

            if (rootPrefetch != null) {
                rootPrefetch.traverse(new PrefetchProcessor() {

                    public void finishPrefetch(PrefetchTreeNode node) {
                    }

                    public boolean startDisjointPrefetch(PrefetchTreeNode node) {
View Full Code Here


        return false;
    }

    private void addPrefetchedColumnsIfAny(final String visitedIdentifier) {
        PrefetchTreeNode prefetchTree = context.getCompiledExpression().getPrefetchTree();
        if (prefetchTree != null) {
            for (PrefetchTreeNode prefetch : prefetchTree.adjacentJointNodes()) {
                ClassDescriptor descriptor = context.getEntityDescriptor(prefetch.getEjbqlPathEntityId());
                if (visitedIdentifier.equals(prefetch.getEjbqlPathEntityId())) {
                    DbEntity table = descriptor.getRootDbEntities().iterator().next();
                    ObjEntity objectEntity = descriptor.getEntity();
                    prefetch.setEntityName(objectEntity.getName());
View Full Code Here

        descriptor.visitProperties(new PropertyVisitor() {

            public boolean visitToOne(ToOneProperty property) {
                if (prefetchTree != null) {

                    PrefetchTreeNode child = prefetchTree.getNode(property.getName());

                    if (child != null) {
                        Object destinationSource = property.readProperty(source);

                        Object destinationTarget = destinationSource != null ? detach(
                                destinationSource,
                                property.getTargetDescriptor(),
                                child) : null;

                        ToOneProperty targetProperty = (ToOneProperty) targetDescriptor
                                .getProperty(property.getName());
                        Object oldTarget = targetProperty.isFault(target)
                                ? null
                                : targetProperty.readProperty(target);
                        targetProperty
                                .writeProperty(target, oldTarget, destinationTarget);
                    }
                }

                return true;
            }

            public boolean visitToMany(ToManyProperty property) {
                if (prefetchTree != null) {
                    PrefetchTreeNode child = prefetchTree.getNode(property.getName());

                    if (child != null) {
                        Object value = property.readProperty(source);
                        Object targetValue;
                       
View Full Code Here

            // a joint prefetch warrants full row compare

            final boolean[] compareFullRows = new boolean[1];

            final PrefetchTreeNode rootPrefetch = md.getPrefetchTree();

            if (rootPrefetch != null) {
                rootPrefetch.traverse(new PrefetchProcessor() {

                    public void finishPrefetch(PrefetchTreeNode node) {
                    }

                    public boolean startDisjointPrefetch(PrefetchTreeNode node) {
View Full Code Here

            return super.visitSubselect(expression);
        }

        private void prepareFetchJoin(EJBQLJoin join) {
            if (prefetchTree == null) {
                prefetchTree = new PrefetchTreeNode();
            }
            EJBQLPath fetchJoin = (EJBQLPath) join.getChild(0);
            addPath(fetchJoin);

            PrefetchTreeNode node = prefetchTree.addPath(fetchJoin.getRelativePath());
            node.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
            node.setPhantom(false);
            node.setEjbqlPathEntityId(fetchJoin.getChild(0).getText());
        }
View Full Code Here

        result.add(descInsensitive());
        return result;
    }

    public PrefetchTreeNode joint() {
        PrefetchTreeNode node = prefetch();
        node.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
        return node;
    }
View Full Code Here

        node.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
        return node;
    }

    public PrefetchTreeNode disjoint() {
        PrefetchTreeNode node = prefetch();
        node.setSemantics(PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS);
        return node;
    }
View Full Code Here

        node.setSemantics(PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS);
        return node;
    }

    public PrefetchTreeNode disjointById() {
        PrefetchTreeNode node = prefetch();
        node.setSemantics(PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
        return node;
    }
View Full Code Here

    PrefetchTreeNode prefetch() {

        // TODO: not very efficient - we are creating a prefetch that
        // SelectQuery would throw away and recreate...
        PrefetchTreeNode root = new PrefetchTreeNode();
        PrefetchTreeNode node = root.addPath(name);
        node.setPhantom(false);
        return node;
    }
View Full Code Here

        @Override
        void convert(List<DataRow> mainRows) {

            ClassDescriptor descriptor = metadata.getClassDescriptor();
            PrefetchTreeNode prefetchTree = metadata.getPrefetchTree();

            PrefetchProcessorNode node = toResultsTree(descriptor, prefetchTree, mainRows);
            List<Persistent> objects = node.getObjects();
            updateResponse(mainRows, objects != null ? objects : new ArrayList<Persistent>(1));
View Full Code Here

TOP

Related Classes of org.apache.cayenne.query.PrefetchTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.