Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.ManageableCollection


                    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


     * @param collectionClass
     * @return
     */
    protected ManageableCollection createCollection(Class collectionClass)
    {
        ManageableCollection col;

        if (collectionClass == null)
        {
            col = new RemovalAwareCollection();
        }
View Full Code Here

        query.bind(new Timestamp(System.currentTimeMillis() - 5000)); // a while ago (effValue3 > $3)
        query.bind(new Integer(20)); // effValue2 <= $4
        query.bind(new Timestamp(System.currentTimeMillis() + 5000)); // a while from now (effValue3<$5)
        query.bind(new Integer(5)); // version.contract.relatedToContract.relatedValue2=$6

        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        /**
         * make sure we got
         */
        int i = 0;
        while (it.hasNext())
View Full Code Here

        query.bind("effValue1.testComplexOQL"); // effValue1 = $2
        query.bind(new Timestamp(System.currentTimeMillis() - 5000)); // a while ago (effValue3 > $3)
        query.bind(new Integer(20)); // effValue2 <= $4
        query.bind(new Timestamp(System.currentTimeMillis() + 5000)); // a while from now (effValue3<$5)

        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        /**
         * make sure we got
         */
        int i = 0;
        while (it.hasNext())
View Full Code Here

        createData(database, odmg);
        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select effectiveness from " + Effectiveness.class.getName() + " where version.versionValue1=$1");
        query.bind("versionvalue1");
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        Effectiveness temp = null;
        while (it.hasNext())
        {
            temp = (Effectiveness) it.next();
            if (!temp.getVersion().getVersionValue1().equals("versionvalue1"))
View Full Code Here

  public void testGetEmbeddedObject() throws Exception
    {
        createData(database, odmg);
        OQLQuery query = odmg.newOQLQuery();
        query.create("select effectiveness.version from " + Effectiveness.class.getName() + " where is_defined(effectiveness.version.versionValue1)");
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        while (it.hasNext())
        {
            assertTrue("Selected item is Version", (it.next() instanceof Version));
        }

        query.create("select effectiveness.version.contract from " + Effectiveness.class.getName() + " where is_defined(effectiveness.version.versionValue1)");
        all = (ManageableCollection) query.execute();
        it = all.ojbIterator();
        while (it.hasNext())
        {
            assertTrue("Selected item is Contract", (it.next() instanceof Contract));
        }
    }
View Full Code Here

        createData(database, odmg);
        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select effectiveness from " + Effectiveness.class.getName() + " where version.contract.contractValue1=$1");
        query.bind("contractvalue1");
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        Effectiveness temp = null;
        while (it.hasNext())
        {
            temp = (Effectiveness) it.next();
            if (!temp.getVersion().getContract().getContractValue1().equals("contractvalue1"))
View Full Code Here

    {
        createData(database, odmg);
        OQLQuery query = odmg.newOQLQuery();
        int i = 0;
        query.create("select effectiveness from " + Effectiveness.class.getName());
        ManageableCollection all = (ManageableCollection) query.execute();
        java.util.Iterator it = all.ojbIterator();
        while (it.hasNext())
        {
            it.next();
            i++;
        }
View Full Code Here

        // 3. Get a list of some articles
        Transaction tx = odmg.newTransaction();

        OQLQuery query = odmg.newOQLQuery();
        ManageableCollection all = null;
        java.util.Iterator it = null;
        int i = 0;
        query.create("select effectiveness from " + org.apache.ojb.broker.Effectiveness.class.getName());

        /**
         * try doing this as part of one transaction, ODMG should figure out
         * which order to delete in.
         */
        all = (ManageableCollection) query.execute();
        // Iterator over the restricted articles objects
        it = all.ojbIterator();
        Effectiveness eff = null;
        Version ver = null;
        Contract contract = null;
        while (it.hasNext())
        {
            eff = (Effectiveness) it.next();
            ver = eff.getVersion();
            contract = ver.getContract();

            tx.begin();
            database.deletePersistent(eff);
            tx.commit();

            tx.begin();
            database.deletePersistent(ver);
            tx.commit();

            tx.begin();
            database.deletePersistent(contract);
            tx.commit();
            // keep the count
            i++;
        }
        if (i < COUNT)
            fail("Should have found at least " + COUNT + " items to delete, only found " + i);
        /**
         * run query again, should get 0 results.
         */
        query.create("select contracts from " + org.apache.ojb.broker.Contract.class.getName());
        ManageableCollection allContracts = (ManageableCollection) query.execute();
        allContracts = (ManageableCollection) query.execute();
        it = allContracts.ojbIterator();
        if (it.hasNext())
        {
            fail("all contracts should have been removed, we found one.");
        }
    }
View Full Code Here

        // 3. Get a list of some articles
        Transaction tx = odmg.newTransaction();

        OQLQuery query = odmg.newOQLQuery();
        ManageableCollection all = null;
        java.util.Iterator it = null;
        int i = 0;
        query.create("select effectiveness from " + org.apache.ojb.broker.Effectiveness.class.getName());

        /**
         * try doing this as part of one transaction, ODMG should figure out
         * which order to delete in.
         */
        all = (ManageableCollection) query.execute();
        // Iterator over the restricted articles objects
        it = all.ojbIterator();
        Effectiveness eff = null;
        Version ver = null;
        Contract contract = null;
        /**
         * should mark all these objects for delete then on commit
         * ODMG should make sure they get deleted in proper order
         */
        tx.begin();
        while (it.hasNext())
        {
            eff = (Effectiveness) it.next();
            ver = eff.getVersion();
            contract = ver.getContract();
            /**
             * should mean that version and effectivedate are cascade deleted.
             */
            database.deletePersistent(contract);
            i++;
        }
        /**
         * commit all changes.
         */
        tx.commit();
        if (i < COUNT)
            fail("Should have found at least " + COUNT + " effectiveness to delete, only found " + i);
        /**
         * run query again, should get 0 results.
         */
        query.create("select contracts from " + org.apache.ojb.broker.Contract.class.getName());
        ManageableCollection allContracts = (ManageableCollection) query.execute();
        allContracts = (ManageableCollection) query.execute();
        it = allContracts.ojbIterator();
        if (it.hasNext())
        {
            fail("all contracts should have been removed, we found one.");
        }
    }
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.