Package org.apache.ojb.broker

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


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

            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

        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

        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

        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

        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

        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

        db.open(databaseName, Database.OPEN_READ_WRITE);
        OQLQuery query = odmg.newOQLQuery();
        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();

        while (it.hasNext())
        {
            a = (BidirectionalAssociationObjectA)it.next();
            b = a.getRelatedB();
View Full Code Here

        db.open(databaseName, Database.OPEN_READ_WRITE);
        OQLQuery query = odmg.newOQLQuery();
        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();

        while (it.hasNext())
        {
            b = (BidirectionalAssociationObjectB)it.next();
            a = b.getRelatedA();
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.ManageableCollection

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.