Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.ManageableCollection


        OQLQuery query = odmg.newOQLQuery();
        String sql = "select effectiveness from " + Effectiveness.class.getName();
        query.create(sql);

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

        // Iterator over the restricted articles objects
        java.util.Iterator it = allEffectiveness.ojbIterator();
        int i = 0;
        while (it.hasNext())
        {
            Effectiveness value = (Effectiveness) it.next();
            /**
 
View Full Code Here


        OQLQuery query = odmg.newOQLQuery();
        String sql = "select version from " + org.apache.ojb.broker.Version.class.getName() + " where pk=$1";
        query.create(sql);
        query.bind("version1");
        tx.begin();
        ManageableCollection results = (ManageableCollection) query.execute();
        // Iterator over the restricted articles objects
        java.util.Iterator it = results.ojbIterator();
        Version ver1 = null;
        while (it.hasNext())
        {
            ver1 = (Version) it.next();
            if (!ver1.getContract().getPk().equals(contract2.getPk()))
            {
                fail(ver1.getPk() + " should have pointed to contract2 instead it pointed to: " + ver1.getContract().getPk());
            }
        }
        tx.commit();

        OQLQuery query2 = odmg.newOQLQuery();
        String sql2 = "select version from " + org.apache.ojb.broker.Version.class.getName() + " where pk=$1";
        query2.create(sql2);
        query2.bind("version2");
        tx.begin();
        results = (ManageableCollection) query2.execute();
        // Iterator over the restricted articles objects
        java.util.Iterator it2 = results.ojbIterator();
        Version ver2 = null;
        while (it2.hasNext())
        {
            ver2 = (Version) it2.next();
            if (!ver2.getContract().getPk().equals(contract.getPk()))
View Full Code Here

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

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

        final boolean isRetrievalTasksCreated = batchRetrieval && m_retrievalTasks == null;
        if (isRetrievalTasksCreated)
        {
            // Maps ReferenceDescriptors to HashSets of owners
            m_retrievalTasks = new HashMap();
        }

        // ==> enable materialization cache
        pb.getInternalCache().enableMaterializationCache();
        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

     * @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

                        }
                        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

                    Array.set(result, j, list.get(j));
                }
            }
            else
            {
                ManageableCollection col = createCollection(collectionClass);

                for (Iterator it2 = list.iterator(); it2.hasNext();)
                {
                    col.ojbAdd(it2.next());
                }
                result = col;
            }

            Object value = field.get(owner);
View Full Code Here

        OQLQuery query = odmg.newOQLQuery();
        String oql =
                "select allPersons from "
                + org.apache.ojb.broker.Person.class.getName();
        query.create(oql);
        ManageableCollection allPersons =
                (ManageableCollection) query.execute();

        // Iterator over the restricted articles objects
        java.util.Iterator it = allPersons.ojbIterator();
        while (it.hasNext())
        {
            db.deletePersistent(it.next());
        }
        tx.commit();
View Full Code Here

        OQLQuery query = odmg.newOQLQuery();
        String sql =
                "select allPersons from "
                + org.apache.ojb.broker.Person.class.getName();
        query.create(sql);
        ManageableCollection allPersons =
                (ManageableCollection) query.execute();
        Iterator it = allPersons.ojbIterator();
        while (it.hasNext())
        {
            db.deletePersistent(it.next());
        }
        tx.commit();
View Full Code Here

            String sql =
                    "select allPersons from "
                    + org.apache.ojb.broker.Person.class.getName();
            query.create(sql);

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

            // Iterator over the restricted articles objects
            java.util.Iterator it = allPersons.ojbIterator();
            int count = 0;
            while (it.hasNext())
            {
                it.next();
                count++;
View Full Code Here

            String sql =
                    "select somePersons from "
                    + org.apache.ojb.broker.Person.class.getName();
            query.create(sql, start, end);

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

            // Iterator over the restricted articles objects
            java.util.Iterator it = somePersons.ojbIterator();
            int count = 0;
            while (it.hasNext())
            {
                it.next();
                count++;
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.