Examples of dList


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

        OQLQuery query = impl.newOQLQuery();

        query.create("select products from " + Product.class.getName() + " where name = $1");
        query.bind(name);

        DList   results = (DList)query.execute();
        Product product = (Product)results.iterator().next();

        tx.commit();
        return product;
    }
View Full Code Here

Examples of org.odmg.DList

     * for the predicate, otherwise false.
     * @exception  org.odmg.QueryInvalidException  The query predicate is invalid.
     */
    public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException
    {
        DList results = (DList) this.query(predicate);
        if (results == null || results.size() == 0)
            return false;
        else
            return true;
    }
View Full Code Here

Examples of org.odmg.DList

            tx.begin();
            OQLQuery query = ojb.newOQLQuery();
            String sql = "select allArticles from " + PerformanceArticle.class.getName() +
                    " where articleName = \"" + PRE_NAME + threadName + "\"";
            query.create(sql);
            DList allProducts = (DList) query.execute();
            tx.commit();

            Iterator iter = allProducts.iterator();
            int fetchCount = 0;
            while (iter.hasNext())
            {
                fetchCount++;
                PerformanceArticle a = (PerformanceArticle) iter.next();
View Full Code Here

Examples of org.odmg.DList

            tx.begin();
            OQLQuery query = ojb.newOQLQuery();
            String sql = "select allFarAways from " + FarAwayClass.class.getName() +
                    " where name = \"" + PRE_NAME + threadName + "\"";
            query.create(sql);
            DList allFarAways = (DList) query.execute();
            tx.commit();
            Iterator iter = allFarAways.iterator();
            int fetchCount = 0;
            while (iter.hasNext())
            {
                fetchCount++;
                FarAwayClass a = (FarAwayClass) iter.next();
View Full Code Here

Examples of org.odmg.DList

        db.open(databaseName, Database.OPEN_READ_WRITE);

        Transaction tx = odmg.newTransaction();
        tx.begin();
        // create DList and bound by name
        DList list = odmg.newDList();
        db.bind(list, name);
        tx.commit();
        tx = odmg.newTransaction();
        tx.begin();
        Object obj = db.lookup(name);
        tx.commit();
        assertNotNull("binded DList not found", obj);

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

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

        tx = odmg.newTransaction();
        tx.begin();
        ((TransactionExt) odmg.currentTransaction()).getBroker().clearCache();

        // lookup list and check entries
        DList lookedUp = (DList) db.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())
        {
            DListObject a = (DListObject) iter.next();
            DListObject b = (DListObject) 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++)
        {
            DListObject a = createObject(name + "_new_entry");
            list.add(a);
        }
        tx.commit();

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

Examples of org.odmg.DList

        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        //open database
        db.open(databaseName, Database.OPEN_READ_WRITE);
        // get DList and fill with objects
        DList list = odmg.newDList();
        Transaction tx = odmg.newTransaction();
        tx.begin();
        for (int i = 0; i < 5; i++)
        {
            DListObject a = createObject(name);
            list.add(a);
        }
        // bind the new list
        db.bind(list, name);
        tx.commit();

        tx = odmg.newTransaction();
        tx.begin();
        Object obj = db.lookup(name);
        tx.commit();
        assertNotNull("binded DList not found", obj);

        // iterate list
        Iterator iter = list.iterator();
        while (iter.hasNext())
        {
            DListObject a = (DListObject) iter.next();
            assertNotNull(a);
        }
        assertEquals(5, list.size());

        tx = odmg.newTransaction();
        tx.begin();
        ((TransactionExt) odmg.currentTransaction()).getBroker().clearCache();
        DList lookedUp = (DList) db.lookup(name);
        tx.commit();
        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())
        {
            DListObject a = (DListObject) iter.next();
            DListObject b = (DListObject) iter1.next();
View Full Code Here

Examples of org.odmg.DList

        //open database
        db.open(databaseName, Database.OPEN_READ_WRITE);
        Transaction tx = odmg.newTransaction();

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

        for (int i = 0; i < 5; i++)
        {
            DListObject 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) db.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) db.lookup(name);
        tx.commit();

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

Examples of org.odmg.DList

        //open database
        db.open(databaseName, Database.OPEN_READ_WRITE);
        Transaction tx = odmg.newTransaction();

        tx.begin();
        DList list = odmg.newDList();
        db.bind(list, name);
        tx.commit();

        tx = odmg.newTransaction();
        tx.begin();
        for (int i = 0; i < 5; i++)
        {
            DListObject 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();
        DListObject a;
        while (iter.hasNext())
        {
            a = (DListObject) iter.next();
            assertNotNull(a);
            //System.out.print(a.getArticleId() + ", ");
        }


        tx = odmg.newTransaction();
        tx.begin();
        ((TransactionImpl) tx).getBroker().clearCache();
        DList lookedUp = (DList) db.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 = (DListObject) iter.next();
        }
        tx.commit();
View Full Code Here

Examples of org.odmg.DList

     * for the predicate, otherwise false.
     * @exception  org.odmg.QueryInvalidException  The query predicate is invalid.
     */
    public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException
    {
        DList results = (DList) this.query(predicate);
        if (results == null || results.size() == 0)
            return false;
        else
            return true;
    }
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.