Package org.apache.ojb.broker.accesslayer

Examples of org.apache.ojb.broker.accesslayer.OJBIterator


     * @return OJBIterator
     */
    protected OJBIterator getIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        RsIteratorFactory factory = RsIteratorFactoryImpl.getInstance();
        OJBIterator result = getRsIteratorFromQuery(query, cld, factory);

        if (query.usePaging())
        {
            result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
        }
View Full Code Here


            ClassDescriptor cld = getClassDescriptor(itemClass);
            /*
            use OJB intern Iterator, thus we are able to close used
            resources instantly
            */
            OJBIterator it = getIteratorFromQuery(query, cld);
            /*
            arminw:
            patch by Andre Clute, instead of taking the first found result
            try to get the first found none null result.
            He wrote:
            I have a situation where an item with a certain criteria is in my
            database twice -- once deleted, and then a non-deleted version of it.
            When I do a PB.getObjectByQuery(), the RsIterator get's both results
            from the database, but the first row is the deleted row, so my RowReader
            filters it out, and do not get the right result.
            */
            try
            {
                while (result==null && it.hasNext())
                {
                    result = it.next();
                }
            } // make sure that we close the used resources
            finally
            {
                if(it != null) it.releaseDbResources();
            }
        }
        return result;
    }
View Full Code Here

     * @return OJBIterator
     */
    private OJBIterator getReportQueryIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        RsIteratorFactory factory = ReportRsIteratorFactoryImpl.getInstance();
        OJBIterator result = getRsIteratorFromQuery(query, cld, factory);

        if (query.usePaging())
        {
            result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
        }
View Full Code Here

    {
        if (log.isDebugEnabled()) log.debug("getCollectionByQuery (" + collectionClass + ", " + itemClass + ", " + query + ")");

        ClassDescriptor cld = pb.getClassDescriptor(itemClass);
        ManageableCollection result = null;
        OJBIterator iter = null;
        boolean isRetrievalTasksCreated = (batchRetrieval && (m_retrievalTasks == null));
        int fullSize = -1;
        int size = 0;

        if (isRetrievalTasksCreated)
        {
            // Maps ReferenceDescriptors to HashSets of owners
            m_retrievalTasks = new HashMap();
        }

        try
        {
            result = (ManageableCollection) collectionClass.newInstance();
            // now iterate over all elements and add them to the new collection
            iter = pb.getIteratorFromQuery(query, cld);

            // BRJ : get fullSizefor Query
            // to be removed when Query.fullSize is removed
            if (iter instanceof PagingIterator)
            {
                fullSize = iter.fullSize();
            }

            while (iter.hasNext())
            {
                Object candidate = iter.next();

                /**
                 * MBAIRD
                 * candidate CAN be null in the case of materializing from an iterator based
                 * on a query for a class that is mapped to a table that has other classes
                 * mapped to that table as well, but aren't extents.
                 */
                if (candidate != null)
                {
                    IndirectionHandler handler = ProxyHelper.getIndirectionHandler(candidate);

                    if ((handler != null)
                            || itemClass.isAssignableFrom(candidate.getClass()))
                    {
                        result.ojbAdd(candidate);

                        // BRJ: count added objects
                        // to be removed when Query.fullSize is removed
                        size++;
                    }
                    else
                    {
                        //warn the user
                        log.warn("Candidate object ["+candidate
                                    +"] class ["+candidate.getClass().getName()
                                    +"] is not a subtype of ["+itemClass.getName()
                                    +"] or any type of proxy. NOT INCLUDED in result collection");
                    }
                    if (prefetchProxies && (handler != null)
                            && (cld.getProxyPrefetchingLimit() > 0)
                            && addRetrievalTask(candidate, this))
                    {
                        new PBMaterializationListener(candidate, m_retrievalTasks,
                                this, cld.getProxyPrefetchingLimit());
                    }
                }
            }


            if (isRetrievalTasksCreated)
            {
                // turn off auto prefetching for related proxies
                Class saveClassToPrefetch = classToPrefetch;
                classToPrefetch = null;
                performRetrievalTasks();
                classToPrefetch = saveClassToPrefetch;
            }
        }
        catch (InstantiationException ex)
        {
            log.error(ex);
            throw new PersistenceBrokerException(ex);
        }
        catch (IllegalAccessException ex)
        {
            log.error(ex);
            throw new PersistenceBrokerException(ex);
        }
        finally
        {
            if (iter != null)
            {
                iter.releaseDbResources();
            }
            if (isRetrievalTasksCreated)
            {
                m_retrievalTasks = null;
            }
View Full Code Here

     * @return OJBIterator
     */
    protected OJBIterator getIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        RsIteratorFactory factory = RsIteratorFactoryImpl.getInstance();
        OJBIterator result = getRsIteratorFromQuery(query, cld, factory);

        if (query.usePaging())
        {
            result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
        }
View Full Code Here

            ClassDescriptor cld = getClassDescriptor(itemClass);
            /*
            use OJB intern Iterator, thus we are able to close used
            resources instantly
            */
            OJBIterator it = getIteratorFromQuery(query, cld);
            Object result = null;
            /*
            arminw:
            patch by Andre Clute, instead of taking the first found result
            try to get the first found none null result.
            He wrote:
            I have a situation where an item with a certain criteria is in my
            database twice -- once deleted, and then a non-deleted version of it.
            When I do a PB.getObjectByQuery(), the RsIterator get's both results
            from the database, but the first row is the deleted row, so my RowReader
            filters it out, and do not get the right result.
            */
            try
            {
                while (result==null && it.hasNext())
                {
                    result = it.next();
                }
            } // make sure that we close the used resources
            finally
            {
                if(it != null) it.releaseDbResources();
            }
            return result;
        }
    }
View Full Code Here

     * @return OJBIterator
     */
    private OJBIterator getReportQueryIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        RsIteratorFactory factory = ReportRsIteratorFactoryImpl.getInstance();
        OJBIterator result = getRsIteratorFromQuery(query, cld, factory);

        if (query.usePaging())
        {
            result = new PagingIterator(result, query.getStartAtIndex(), query.getEndAtIndex());
        }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.accesslayer.OJBIterator

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.