Examples of ManageableCollection


Examples of org.apache.ojb.broker.ManageableCollection

            throws ClassNotPersistenceCapableException, PersistenceBrokerException
    {
        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++;
                    }
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

     * @return ManageableCollection
     * @throws PersistenceBrokerException
     */
    public ManageableCollection getCollectionByQuery(Class collectionClass, Query query, boolean lazy) throws PersistenceBrokerException
    {
        ManageableCollection result;

        try
        {
            // BRJ: return empty Collection  for null query
            if (query == null)
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

                    }
                    value = result;
                }
                else
                {
                    ManageableCollection result = getCollectionByQuery(collectionClass, fkQuery, cds.isLazy());
                    collectionField.set(obj, result);
                    value = result;
                }

                if (prefetchProxies && (m_retrievalTasks != null)
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        //obtain current ODMG transaction
        Transaction tx = TxManagerFactory.instance().getTransaction();
        // create PBCapsule
        PBCapsule capsule = null;
        ManageableCollection result = null;

        try
        {
            capsule = new PBCapsule(pbKey, tx);
            PersistenceBroker broker = capsule.getBroker();

            // ask the broker to perfom the query.
            // the concrete result type is configurable

            if (!(query instanceof ReportQuery))
            {
                result = broker.getCollectionByQuery(this.getCollectionClass(), query);
                performLockingIfRequired(tx, broker, result);
            }
            else
            {
                Iterator iter = null;
                result = new ManageableArrayList();
                iter = broker.getReportQueryIteratorByQuery(query);
                try
                {
                    while (iter.hasNext())
                    {
                        Object[] res = (Object[]) iter.next();

                        if (res.length == 1)
                        {
                            if (res[0] != null) // skip null values
                            {
                                result.ojbAdd(res[0]);
                            }
                        }
                        else
                        {
                            // skip null tuples
                            for (int i = 0; i < res.length; i++)
                            {
                                if (res[i] != null)
                                {
                                    result.ojbAdd(res);
                                    break;
                                }
                            }
                        }
                    }
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

            OQLQuery query = odmg.newOQLQuery();
            String sql = "select aPerson.firstname, aPerson.lastname from " + org.apache.ojb.broker.Person.class.getName();
            query.create(sql);

            ManageableCollection result = (ManageableCollection) query.execute();

            // Iterator over the restricted articles objects
            java.util.Iterator it = result.ojbIterator();
            int i = 0;
            while (it.hasNext())
            {
                Object[] res = (Object[]) it.next();
                String firstname = (String) res[0];
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        db.open(databaseName, Database.OPEN_READ_WRITE);
        OQLQuery query = odmg.newOQLQuery();
        String sql = "select allArticles from " + PerformanceArticle.class.getName() + " where articleId between " + new Integer(offsetId) + " and " + new Integer(offsetId + articleCount);
        query.create(sql);
        long start = System.currentTimeMillis();
        ManageableCollection collection = (ManageableCollection) query.execute();
        Iterator iter = collection.ojbIterator();
        int fetchCount = 0;
        while (iter.hasNext())
        {
            fetchCount++;
            PerformanceArticle a = (PerformanceArticle) iter.next();
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        tx.begin();
        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select bidirectionalAssociationObjectA from " + BidirectionalAssociationObjectA.class.getName() + " where pk=$1");
        query.bind("A"+currentTime);
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        while (it.hasNext())
        {
            i++;
            a = (BidirectionalAssociationObjectA) it.next();
            if (a.getRelatedB() == null)
                fail("a should have had a related b");
        }
        if (i > 1)
            fail("should have found only one bidirectionalAssociationObjectA, instead found: " + i);

        query = odmg.newOQLQuery();
        i = 0;
        query.create("select bidirectionalAssociationObjectB from " + BidirectionalAssociationObjectB.class.getName() + " where pk=$1");
        query.bind("B"+currentTime);
        all = (ManageableCollection) query.execute();
        it = all.ojbIterator();
        while (it.hasNext())
        {
            i++;
            b = (BidirectionalAssociationObjectB) it.next();
            if (b.getRelatedA() == null)
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        tx.begin();
        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select bidirectionalAssociationObjectA from " + BidirectionalAssociationObjectA.class.getName() + " where pk=$1");
        query.bind("A"+currentTime);
         ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        while (it.hasNext())
        {
            i++;
            it.next();
        }
        if (i > 1)
            fail("should have found only one bidirectionalAssociationObjectA, instead found: " + i);

        query = odmg.newOQLQuery();
        i = 0;
        query.create("select bidirectionalAssociationObjectB from " + BidirectionalAssociationObjectB.class.getName() + " where pk=$1");
        query.bind("B"+currentTime);
        all = (ManageableCollection) query.execute();
        it = all.ojbIterator();
        while (it.hasNext())
        {
            i++;
            it.next();
        }
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select bidirectionalAssociationObjectA from " + BidirectionalAssociationObjectA.class.getName());
        Transaction tx = odmg.newTransaction();
        tx.begin();
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        BidirectionalAssociationObjectA temp = null;
        while (it.hasNext())
        {
            temp = (BidirectionalAssociationObjectA) it.next();
            if (temp.getRelatedB() == null)
View Full Code Here

Examples of org.apache.ojb.broker.ManageableCollection

        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select bidirectionalAssociationObjectB from " + BidirectionalAssociationObjectB.class.getName());
        Transaction tx = odmg.newTransaction();
        tx.begin();
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        BidirectionalAssociationObjectB temp = null;
        while (it.hasNext())
        {
            temp = (BidirectionalAssociationObjectB) it.next();
            if (temp.getRelatedA() == null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.