Package org.apache.cayenne.access

Examples of org.apache.cayenne.access.ResultIterator


            this.keyRowDescriptor = builder
                    .getDescriptor(getAdapter().getExtendedTypes());
        }

        ResultIterator iterator = new JDBCResultIterator(
                null,
                null,
                keysRS,
                keyRowDescriptor,
                0);
View Full Code Here


                query.getFetchLimit());

        workerIterator.setPostProcessor(DataRowPostProcessor
                .createPostProcessor(translator));

        ResultIterator it = workerIterator;

        // wrap result iterator if distinct has to be suppressed
        if (translator.isSuppressingDistinct()) {

            // 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) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startUnknownPrefetch(PrefetchTreeNode node) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startJointPrefetch(PrefetchTreeNode node) {
                        if (rootPrefetch != node) {
                            compareFullRows[0] = true;
                            return false;
                        }

                        return true;
                    }

                    public boolean startPhantomPrefetch(PrefetchTreeNode node) {
                        return true;
                    }
                });
            }

            it = new DistinctResultIterator(
                    workerIterator,
                    translator.getRootDbEntity(),
                    compareFullRows[0]);
        }

        // TODO: Should do something about closing ResultSet and PreparedStatement in this
        // method, instead of relying on DefaultResultIterator to do that later

        if (!observer.isIteratedResult()) {
            // note that we don't need to close ResultIterator
            // since "dataRows" will do it internally
            List<DataRow> resultRows = it.dataRows(true);
            QueryLogger
                    .logSelectCount(resultRows.size(), System.currentTimeMillis() - t1);

            observer.nextDataRows(query, resultRows);
        }
        else {
            try {
                workerIterator.setClosingConnection(true);
                observer.nextDataRows(translator.getQuery(), it);
            }
            catch (Exception ex) {
                it.close();
                throw ex;
            }
        }
    }
View Full Code Here

                md);

        workerIterator.setPostProcessor(DataRowPostProcessor
                .createPostProcessor(translator));

        ResultIterator it = workerIterator;

        // wrap result iterator if distinct has to be suppressed
        if (translator.isSuppressingDistinct()) {

            // 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) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startUnknownPrefetch(PrefetchTreeNode node) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startJointPrefetch(PrefetchTreeNode node) {
                        if (rootPrefetch != node) {
                            compareFullRows[0] = true;
                            return false;
                        }

                        return true;
                    }

                    public boolean startPhantomPrefetch(PrefetchTreeNode node) {
                        return true;
                    }
                });
            }

            it = new DistinctResultIterator(
                    workerIterator,
                    translator.getRootDbEntity(),
                    compareFullRows[0]);
        }

        // wrap iterator in a fetch limit checker ... there are a few cases when in-memory
        // fetch limit is a noop, however in a general case this is needed, as the SQL
        // result count does not directly correspond to the number of objects returned
        // from Cayenne.

        int fetchLimit = query.getFetchLimit();
        int offset = getInMemoryOffset(query.getFetchOffset());
        if (fetchLimit > 0 || offset > 0) {
            it = new LimitResultIterator(it, offset, fetchLimit);
        }

        // TODO: Should do something about closing ResultSet and PreparedStatement in this
        // method, instead of relying on DefaultResultIterator to do that later

        if (!observer.isIteratedResult()) {
            // note that we don't need to close ResultIterator
            // since "dataRows" will do it internally

            List<DataRow> resultRows;
            try {
                resultRows = (List<DataRow>) it.allRows();
            }
            finally {
                it.close();
            }

            QueryLogger
                    .logSelectCount(resultRows.size(), System.currentTimeMillis() - t1);

            observer.nextRows(query, resultRows);
        }
        else {
            try {
                workerIterator.setClosingConnection(true);
                observer.nextRows(translator.getQuery(), it);
            }
            catch (Exception ex) {
                it.close();
                throw ex;
            }
        }
    }
View Full Code Here

            this.keyRowDescriptor = builder
                    .getDescriptor(getAdapter().getExtendedTypes());
        }

        ResultIterator iterator = new JDBCResultIterator(
                null,
                null,
                keysRS,
                keyRowDescriptor);
View Full Code Here

                descriptor);

        workerIterator.setPostProcessor(DataRowPostProcessor
                .createPostProcessor(translator));

        ResultIterator it = workerIterator;

        // wrap result iterator if distinct has to be suppressed
        if (translator.isSuppressingDistinct()) {

            // 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) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startUnknownPrefetch(PrefetchTreeNode node) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startJointPrefetch(PrefetchTreeNode node) {
                        if (rootPrefetch != node) {
                            compareFullRows[0] = true;
                            return false;
                        }

                        return true;
                    }

                    public boolean startPhantomPrefetch(PrefetchTreeNode node) {
                        return true;
                    }
                });
            }

            it = new DistinctResultIterator(
                    workerIterator,
                    translator.getRootDbEntity(),
                    compareFullRows[0]);
        }

        // wrap iterator in a fetch limit checker ... there are a few cases when in-memory
        // fetch limit is a noop, however in a geberal case this is needed, as teh SQL
        // result count does not directly correspind to the number of objects returned
        // from Cayenne.

        int fetchLimit = query.getFetchLimit();
        int offset = getInMemoryOffset(query.getFetchOffset());
        if (fetchLimit > 0 || offset > 0) {
            it = new LimitResultIterator(it, offset, fetchLimit);
        }

        // TODO: Should do something about closing ResultSet and PreparedStatement in this
        // method, instead of relying on DefaultResultIterator to do that later

        if (!observer.isIteratedResult()) {
            // note that we don't need to close ResultIterator
            // since "dataRows" will do it internally
            List<DataRow> resultRows = it.dataRows(true);
            QueryLogger
                    .logSelectCount(resultRows.size(), System.currentTimeMillis() - t1);

            observer.nextDataRows(query, resultRows);
        }
        else {
            try {
                workerIterator.setClosingConnection(true);
                observer.nextDataRows(translator.getQuery(), it);
            }
            catch (Exception ex) {
                it.close();
                throw ex;
            }
        }
    }
View Full Code Here

            this.keyRowDescriptor = builder
                    .getDescriptor(getAdapter().getExtendedTypes());
        }

        ResultIterator iterator = new JDBCResultIterator(
                null,
                null,
                keysRS,
                keyRowDescriptor,
                query.getMetaData(getEntityResolver()));
View Full Code Here

                md);

        workerIterator.setPostProcessor(DataRowPostProcessor
                .createPostProcessor(translator));

        ResultIterator it = workerIterator;

        // wrap result iterator if distinct has to be suppressed
        if (translator.isSuppressingDistinct()) {

            // 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) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startUnknownPrefetch(PrefetchTreeNode node) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startJointPrefetch(PrefetchTreeNode node) {
                        if (rootPrefetch != node) {
                            compareFullRows[0] = true;
                            return false;
                        }

                        return true;
                    }

                    public boolean startPhantomPrefetch(PrefetchTreeNode node) {
                        return true;
                    }
                });
            }

            it = new DistinctResultIterator(
                    workerIterator,
                    translator.getRootDbEntity(),
                    compareFullRows[0]);
        }

        // wrap iterator in a fetch limit checker ... there are a few cases when in-memory
        // fetch limit is a noop, however in a general case this is needed, as the SQL
        // result count does not directly correspond to the number of objects returned
        // from Cayenne.

        int fetchLimit = query.getFetchLimit();
        int offset = translator.isSuppressingDistinct() ? query.getFetchOffset()
                : getInMemoryOffset(query.getFetchOffset());
        if (fetchLimit > 0 || offset > 0) {
            it = new LimitResultIterator(it, offset, fetchLimit);
        }

        // TODO: Should do something about closing ResultSet and PreparedStatement in this
        // method, instead of relying on DefaultResultIterator to do that later

        if (!observer.isIteratedResult()) {
            // note that we don't need to close ResultIterator
            // since "dataRows" will do it internally

            List<DataRow> resultRows;
            try {
                resultRows = (List<DataRow>) it.allRows();
            }
            finally {
                it.close();
            }

            adapter.getJdbcEventLogger().logSelectCount(
                    resultRows.size(),
                    System.currentTimeMillis() - t1);
            observer.nextRows(query, resultRows);
        }
        else {
            try {
                workerIterator.setClosingConnection(true);
                observer.nextRows(translator.getQuery(), it);
            }
            catch (Exception ex) {
                it.close();
                throw ex;
            }
        }
    }
View Full Code Here

                md);

        workerIterator.setPostProcessor(DataRowPostProcessor
                .createPostProcessor(translator));

        ResultIterator it = workerIterator;

        // wrap result iterator if distinct has to be suppressed
        if (translator.isSuppressingDistinct()) {

            // 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) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startUnknownPrefetch(PrefetchTreeNode node) {
                        // continue to children only if we are at root
                        return rootPrefetch == node;
                    }

                    public boolean startJointPrefetch(PrefetchTreeNode node) {
                        if (rootPrefetch != node) {
                            compareFullRows[0] = true;
                            return false;
                        }

                        return true;
                    }

                    public boolean startPhantomPrefetch(PrefetchTreeNode node) {
                        return true;
                    }
                });
            }

            it = new DistinctResultIterator(
                    workerIterator,
                    translator.getRootDbEntity(),
                    compareFullRows[0]);
        }

        // wrap iterator in a fetch limit checker ... there are a few cases when in-memory
        // fetch limit is a noop, however in a general case this is needed, as the SQL
        // result count does not directly correspond to the number of objects returned
        // from Cayenne.

        int fetchLimit = query.getFetchLimit();
        int offset = getInMemoryOffset(query.getFetchOffset());
        if (fetchLimit > 0 || offset > 0) {
            it = new LimitResultIterator(it, offset, fetchLimit);
        }

        // TODO: Should do something about closing ResultSet and PreparedStatement in this
        // method, instead of relying on DefaultResultIterator to do that later

        if (!observer.isIteratedResult()) {
            // note that we don't need to close ResultIterator
            // since "dataRows" will do it internally

            List<DataRow> resultRows;
            try {
                resultRows = (List<DataRow>) it.allRows();
            }
            finally {
                it.close();
            }

            QueryLogger
                    .logSelectCount(resultRows.size(), System.currentTimeMillis() - t1);

            observer.nextRows(query, resultRows);
        }
        else {
            try {
                workerIterator.setClosingConnection(true);
                observer.nextRows(translator.getQuery(), it);
            }
            catch (Exception ex) {
                it.close();
                throw ex;
            }
        }
    }
View Full Code Here

            this.keyRowDescriptor = builder
                    .getDescriptor(getAdapter().getExtendedTypes());
        }

        ResultIterator iterator = new JDBCResultIterator(
                null,
                null,
                keysRS,
                keyRowDescriptor,
                query.getMetaData(getEntityResolver()));
View Full Code Here

            this.keyRowDescriptor = builder
                    .getDescriptor(getAdapter().getExtendedTypes());
        }

        ResultIterator iterator = new JDBCResultIterator(
                null,
                null,
                keysRS,
                keyRowDescriptor,
                query.getMetaData(getEntityResolver()));
View Full Code Here

TOP

Related Classes of org.apache.cayenne.access.ResultIterator

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.