Package org.apache.cayenne.query

Examples of org.apache.cayenne.query.PrefetchTreeNode


     */
    private void buildRowMapping() {
        final Map<String, ColumnDescriptor> targetSource = new TreeMap<String, ColumnDescriptor>();

        // build a DB path .. find parent node that terminates the joint group...
        PrefetchTreeNode jointRoot = this;
        while (jointRoot.getParent() != null && !jointRoot.isDisjointPrefetch()) {
            jointRoot = jointRoot.getParent();
        }

        final String prefix;
        if (jointRoot != this) {
            Expression objectPath = Expression.fromString(getPath(jointRoot));
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
View Full Code Here

            for (int i = 0; i < len; i++) {
                rowsColumn.add((DataRow) rows.get(i)[position]);
            }

            if (prefetchTree != null) {
                PrefetchTreeNode prefetchTreeNode = null;
                for (PrefetchTreeNode prefetch : prefetchTree.getChildren()) {
                    if (descriptor.getEntity().getName().equals(prefetch.getEntityName())) {
                        if (prefetchTreeNode == null) {
                            prefetchTreeNode = new PrefetchTreeNode();
                        }
                        PrefetchTreeNode addPath = prefetchTreeNode.addPath(prefetch
                                .getPath());
                        addPath.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
                        addPath.setPhantom(false);
                    }
                }
                prefetchTree = prefetchTreeNode;
            }
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) {
                        Collection collection = (Collection) property
                                .readProperty(source);
View Full Code Here

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

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

            List<Persistent> objects = toObjects(descriptor, prefetchTree, mainRows);
            updateResponse(mainRows, objects);

            // apply POST_LOAD callback
View Full Code Here

        }

        ObjEntity entity = metadata.getObjEntity();
        Iterator prefetchesIt = prefetches.iterator();
        while (prefetchesIt.hasNext()) {
            PrefetchTreeNode prefetch = (PrefetchTreeNode) prefetchesIt.next();
            String path = prefetch.getPath();
            if (path.indexOf('.') >= 0) {
                throw new CayenneRuntimeException("Only one-step relationships are "
                        + "supported at the moment, this will be fixed soon. "
                        + "Unsupported path : "
                        + path);
View Full Code Here

            // 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

            else {
                normalized = mainRows;
            }

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

            List<Persistent> objects = toObjects(descriptor, prefetchTree, normalized);
            updateResponse(mainRows, objects);

            // apply POST_LOAD callback
View Full Code Here

     */
    private void buildRowMapping() {
        Map<String, ColumnDescriptor> targetSource = new TreeMap<String, ColumnDescriptor>();

        // build a DB path .. find parent node that terminates the joint group...
        PrefetchTreeNode jointRoot = this;
        while (jointRoot.getParent() != null && !jointRoot.isDisjointPrefetch()) {
            jointRoot = jointRoot.getParent();
        }

        String prefix;
        if (jointRoot != this) {
            Expression objectPath = Expression.fromString(getPath(jointRoot));
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
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.