Package org.apache.cayenne.query

Examples of org.apache.cayenne.query.PrefetchTreeNode$CollectionBuilderOperation


            List mainRows = response.firstList();
            if (mainRows != null && !mainRows.isEmpty()) {

                List objects;
                ObjEntity entity = metadata.getObjEntity();
                PrefetchTreeNode prefetchTree = metadata.getPrefetchTree();

                // take a shortcut when no prefetches exist...
                if (prefetchTree == null) {
                    objects = new ObjectResolver(context, entity, metadata
                            .isRefreshingObjects(), metadata.isResolvingInherited())
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

            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

        if (!serverObjects.isEmpty()) {
            ObjectDetachOperation op = new ObjectDetachOperation(serverResolver
                    .getClientEntityResolver());
            Iterator it = serverObjects.iterator();
            PrefetchTreeNode prefetchTree = serverMetadata.getPrefetchTree();

            while (it.hasNext()) {
                Persistent object = (Persistent) it.next();
                ObjectId id = object.getObjectId();
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

        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

                        + "#result('DATE_OF_BIRTH' 'java.util.Date'), "
                        + "#result('t0.ARTIST_ID' 'int' '' 'ARTIST_ID') "
                        + "FROM ARTIST t0, PAINTING t1 "
                        + "WHERE t0.ARTIST_ID = t1.ARTIST_ID");

        PrefetchTreeNode prefetch = q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
        assertEquals(
                "Default semantics for SQLTemplate is assumed to be joint.",
                PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS,
                prefetch.getSemantics());
        q.setFetchingDataRows(false);

        DataContext context = createDataContext();

        List objects = context.performQuery(q);
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

            public boolean isResolvingInherited() {
                return true;
            }
        };

        PrefetchTreeNode tree = new PrefetchTreeNode();
        HierarchicalObjectResolver resolver = new HierarchicalObjectResolver(
                createDataContext(),
                metadata);
        PrefetchProcessorTreeBuilder builder = new PrefetchProcessorTreeBuilder(
                resolver,
View Full Code Here

        ObjEntity e5 = getObjEntity("ArtistExhibit");

        List mainRows = new ArrayList();
        Map extraRows = new HashMap();

        PrefetchTreeNode tree = new PrefetchTreeNode();
        tree.addPath(Artist.PAINTING_ARRAY_PROPERTY).setPhantom(false);
        tree.addPath(
                Artist.PAINTING_ARRAY_PROPERTY
                        + "."
                        + Painting.TO_GALLERY_PROPERTY
                        + "."
                        + Gallery.EXHIBIT_ARRAY_PROPERTY).setPhantom(false);
        tree.addPath(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY).setPhantom(false);

        QueryMetadata metadata = new MockQueryMetadata() {

            @Override
            public ClassDescriptor getClassDescriptor() {
View Full Code Here

TOP

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

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.