Examples of dList


Examples of org.odmg.DList

            // Check stored objects
            OQLQuery query = odmg.newOQLQuery();
            query.create("select masters from " + Master.class.getName() + " where masterText like $1");
            query.bind("%" + timestamp);
            DList allMasters = (DList) query.execute();
            assertEquals("We should found master objects", 2, allMasters.size());
            Master lookup_1 = (Master) allMasters.get(0);
            Collection col_in = lookup_1.getCollDetailFKinPK();
            Collection col_no = lookup_1.getCollDetailFKnoPK();
            assertEquals("Should found none " + DetailFKnoPK.class.getName() + " objects", 0, col_no.size());
            assertEquals("Should found " + DetailFKinPK.class.getName() + " objects", 5, col_in.size());
        }
View Full Code Here

Examples of org.odmg.DList

            tx.begin();
            OQLQuery query = odmg.newOQLQuery();
            query.create("select masters from " + Master.class.getName() + " where masterText like $1");
            query.bind("%" + timestamp);
            DList allMasters = (DList) query.execute();

            // Iterator over all Master objects
            Iterator it = allMasters.iterator();
            int counter = 0;
            while (it.hasNext())
            {
                ++counter;
                Master aMaster = (Master) it.next();
                Iterator it2 = aMaster.collDetailFKinPK.iterator();
                while (it2.hasNext())
                    database.deletePersistent(it2.next());
                it2 = aMaster.collDetailFKnoPK.iterator();
                while (it2.hasNext())
                    database.deletePersistent(it2.next());
                database.deletePersistent(aMaster);
            }
            tx.commit();
            assertEquals("Wrong count of Master objects found", 4, counter);

            query = odmg.newOQLQuery();
            query.create("select masters from " + Master.class.getName() + " where masterText like $1");
            query.bind("%" + timestamp);
            allMasters = (DList) query.execute();
            assertEquals("Delete of Master objects failed", 0, allMasters.size());

            database.close();
        }
        finally
        {
View Full Code Here

Examples of org.odmg.DList

        {
            tx.begin();

            OQLQuery query = odmg.newOQLQuery();
            query.create("select x from " + Article.class.getName() + " where productGroupId = 7");
            DList results = (DList) query.execute();

            int originalSize = results.size();
            assertTrue("result count have to be > 0", originalSize > 0);

//            OJB.getLogger().debug(results);

            String name = "gimme fruits_" + System.currentTimeMillis();

            db.bind(results, name);
            tx.commit();

            tx = odmg.newTransaction();
            tx.begin();

            ((TransactionImpl) tx).getBroker().clearCache();

            // look it up again
            DList newResults = (DList) db.lookup(name);

            assertEquals(originalSize, newResults.size());
            Article art = (Article) newResults.get(0);
            assertNotNull(art);
//            OJB.getLogger().info(results);

            tx.commit();
View Full Code Here

Examples of org.odmg.DList

    }

    protected int getObjectCount(Implementation ojb, Class target)
    {
        if(log.isDebugEnabled()) log.debug("getObjectCount was called");
        DList list;
        try
        {
            OQLQuery query = ojb.newOQLQuery();
            query.create("select allObjects from " + target.getName());
            list = (DList) query.execute();
            return list.size();
        }
        catch (QueryException e)
        {
            throw new EJBException("Query objects failed", e);
        }
View Full Code Here

Examples of org.odmg.DList

            ((HasBroker) tx).getBroker().clearCache();
            OQLQuery qry = odmg.newOQLQuery();
            qry.create("select a from " + PersonImpl.class.getName() + " where firstname=$1");
            qry.bind("Kevin");

            DList result = (DList) qry.execute();
            Person boy = (Person) result.get(0);
            assertEquals(boy.getFirstname(), kevin.getFirstname());
            assertEquals(boy.getFather().getFirstname(), dad.getFirstname());
            assertEquals(boy.getMother().getFirstname(), mum.getFirstname());

            tx.commit();
View Full Code Here

Examples of org.odmg.DList

        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        //bind object to name
        tx.begin();

        // get new DList instance
        DList dlist = odmg.newDList();
        Article a1 = createArticle();
        Article a2 = createArticle();
        Article a3 = createArticle();
        dlist.add(a1);
        dlist.add(a2);
        dlist.add(a3);
        database.bind(dlist, bindingName);
        // lookup the named object - DList
        List value = (List) database.lookup(bindingName);
        assertNotNull("Could not lookup object for binding name: "+bindingName, value);
        tx.commit();
View Full Code Here

Examples of org.odmg.DList

        final String name = "testAdding_" + System.currentTimeMillis();

        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        // create DList and bound by name
        DList list = odmg.newDList();
        database.bind(list, name);
        tx.commit();

        tx.begin();
        tx.getBroker().clearCache();
        Object obj = database.lookup(name);
        tx.commit();
        assertNotNull("binded DList not found", obj);

        tx.begin();
        // add objects to list
        for (int i = 0; i < 5; i++)
        {
            DObject a = createObject(name);
            list.add(a);
        }
        tx.commit();

        // check current list
        Iterator iter = list.iterator();
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
            assertNotNull(a);
        }

        tx.begin();
        tx.getBroker().clearCache();

        // lookup list and check entries
        DList lookedUp = (DList) database.lookup(name);
        assertNotNull("binded DList not found", lookedUp);

        //System.out.println("sequence of items in lookedup list:");
        iter = lookedUp.iterator();
        Iterator iter1 = list.iterator();
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
            DObject b = (DObject) iter1.next();
            assertNotNull(a);
            assertNotNull(b);
            assertEquals(a.getId(), b.getId());
        }
        tx.commit();

        // add new entries to list
        tx.begin();
        for (int i = 0; i < 3; i++)
        {
            DObject a = createObject(name + "_new_entry");
            list.add(a);
        }
        tx.commit();

        tx.begin();
        tx.getBroker().clearCache();
        lookedUp = (DList) database.lookup(name);
        iter = lookedUp.iterator();
        iter1 = list.iterator();
        assertEquals("Wrong number of DListEntry found", 8, list.size());
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
View Full Code Here

Examples of org.odmg.DList

        final String name = "testRemoveAdd_" + System.currentTimeMillis();

        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        // create DList and bound by name
        DList list = odmg.newDList();
        database.bind(list, name);

        // add object to list
        for (int i = 0; i < 5; i++)
        {
            DObject a = createObject(name);
            list.add(a);
        }
        tx.commit();

        // check current list
        Iterator iter = list.iterator();
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
            assertNotNull(a);
        }

        tx.begin();
        tx.getBroker().clearCache();

        // lookup list and check entries
        DList lookedUp = (DList) database.lookup(name);
        assertNotNull("binded DList not found", lookedUp);

        //System.out.println("sequence of items in lookedup list:");
        iter = lookedUp.iterator();
        Iterator iter1 = list.iterator();
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
            DObject b = (DObject) iter1.next();
            assertNotNull(a);
            assertNotNull(b);
            assertEquals(a.getId(), b.getId());
        }
        tx.commit();

        // add and remove new entries
        tx.begin();
        for (int i = 0; i < 3; i++)
        {
            DObject a = createObject(name + "_new_entry_NOT_PERSIST");
            list.add(a);
            list.remove(list.size()-1);
        }
        tx.commit();


        tx.begin();
        tx.getBroker().clearCache();
        lookedUp = (DList) database.lookup(name);
        iter = lookedUp.iterator();
        iter1 = list.iterator();
        assertEquals("Wrong number of DListEntry found", 5, list.size());
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
            DObject b = (DObject) iter1.next();
            assertNotNull(a);
            assertNotNull(b);
            assertEquals(a.getId(), b.getId());
        }
        tx.commit();
        assertNotNull("binded DList not found", lookedUp);


        tx.begin();
        for (int i = 0; i < 3; i++)
        {
            DObject a = createObject(name + "_new_entry_new_persist");
            list.add(a);
            list.remove(0);
        }
        tx.commit();

        tx.begin();
        tx.getBroker().clearCache();
        lookedUp = (DList) database.lookup(name);
        iter = lookedUp.iterator();
        iter1 = list.iterator();
        assertEquals("Wrong number of DListEntry found", 5, list.size());
        while (iter.hasNext())
        {
            DObject a = (DObject) iter.next();
View Full Code Here

Examples of org.odmg.DList

        // create a unique name:
        String name = "testRemoving_" + System.currentTimeMillis();

        Transaction tx = odmg.newTransaction();
        tx.begin();
        DList list = odmg.newDList();
        // bind the list to the name:
        database.bind(list, name);

        for (int i = 0; i < 5; i++)
        {
            DObject a = createObject(name);
            list.add(a);
        }
        assertEquals(5, list.size());
        tx.commit();

        // delete two items
        tx = odmg.newTransaction();
        tx.begin();
        ((HasBroker) odmg.currentTransaction()).getBroker().clearCache();
        DList lookedUp = (DList) database.lookup(name);
        assertNotNull("database lookup does not find the named DList", lookedUp);
        assertEquals("Wrong number of list entries", 5, lookedUp.size());
        lookedUp.remove(2);
        lookedUp.remove(1);
        tx.commit();

        // check if deletion was successful
        tx = odmg.newTransaction();
        tx.begin();
        ((HasBroker) odmg.currentTransaction()).getBroker().clearCache();
        lookedUp = (DList) database.lookup(name);
        tx.commit();

        assertEquals(3, lookedUp.size());
    }
View Full Code Here

Examples of org.odmg.DList

        // create a unique name:
        String name = "testAddingWithIndex_" + System.currentTimeMillis();

        Transaction tx = odmg.newTransaction();
        tx.begin();
        DList list = odmg.newDList();
        database.bind(list, name);
        tx.commit();

        tx = odmg.newTransaction();
        tx.begin();
        for (int i = 0; i < 5; i++)
        {
            DObject a = createObject(name);
            list.add(a);
        }

        list.add(2, createObject(name+"_pos2"));
        list.add(0, createObject(name+"_pos0"));
        list.add(7, createObject(name+"_pos7"));
        tx.commit();

        tx.begin();
        ((TransactionImpl) tx).getBroker().clearCache();
        // System.out.println("list: " + list);
        // System.out.println("lookup list: " + db.lookup(name));
        tx.commit();

        //System.out.println("sequence of items in list:");
        Iterator iter = list.iterator();
        DObject a;
        while (iter.hasNext())
        {
            a = (DObject) iter.next();
            assertNotNull(a);
            //System.out.print(a.getArticleId() + ", ");
        }


        tx = odmg.newTransaction();
        tx.begin();
        ((TransactionImpl) tx).getBroker().clearCache();
        DList lookedUp = (DList) database.lookup(name);
        // System.out.println("lookup list: " + lookedUp);
        assertNotNull("database lookup does not find DList", lookedUp);
        assertEquals(8, lookedUp.size());
        iter = lookedUp.iterator();
        while (iter.hasNext())
        {
            a = (DObject) iter.next();
        }
        tx.commit();
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.