Package org.odmg

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


     * 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

        Criteria pCrit = pQ.getCriteria();

        Transaction tx = TxManagerFactory.instance().getTransaction();
        if (tx == null) throw new QueryInvalidException("Need running transaction to do query");
        PBCapsule handle = new PBCapsule(pbKey, tx);
        DList result;
        try
        {
            PersistenceBroker broker = handle.getBroker();
            Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
            // join selection of elements with predicate criteria:
View Full Code Here

     * Constructor for ODMGGourmet.
     */
    public ODMGGourmet()
    {
        super();
        DList list = DCollectionFactory.getInstance().createDList(TestHelper.DEF_KEY);
        this.setFavoriteFood(list);
    }
View Full Code Here

     * @param name
     */
    public ODMGGourmet(String name)
    {
        super(name);
        DList list = DCollectionFactory.getInstance().createDList(TestHelper.DEF_KEY);
        this.setFavoriteFood(list);
    }
View Full Code Here

     * 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

        predicateQuery.create(oql);
        Query pQ = ((OQLQueryImpl) predicateQuery).getQuery();
        Criteria pCrit = pQ.getCriteria();

        PBCapsule handle = new PBCapsule(pbKey, TxManagerFactory.instance().getTransaction());
        DList result;

        try
        {
            PersistenceBroker broker = handle.getBroker();
View Full Code Here

    public void testDoubleBindInOneTx() throws Exception
    {
        String bindingName = "testDoubleBindInOneTx_" + System.currentTimeMillis();

        DList foundList = null;
        Transaction tx = odmg.newTransaction();
        tx.begin();
        database.bind(odmg.newDList(), bindingName);

        foundList = (DList)database.lookup(bindingName);
        assertTrue("Could not found bound DList", foundList != null);
        foundList = null;

        database.unbind(bindingName);
        try
        {
            foundList = (DList) database.lookup(bindingName);
            fail("Found unbound DList");
        }
        catch (ObjectNameNotFoundException ex)
        {
        }

        database.bind(odmg.newDList(), bindingName);
        try
        {
            foundList = (DList) database.lookup(bindingName);
        }
        catch (ObjectNameNotFoundException ex)
        {
            fail("Could not found bound DList, binding name was: "+bindingName);
        }
        foundList = null;
        tx.commit();

        tx = odmg.newTransaction();
        tx.begin();
        try
        {
            DList newList = (DList) database.lookup(bindingName);
            assertNotNull(newList);
            database.unbind(bindingName);
        }
        catch (ObjectNameNotFoundException ex)
        {
View Full Code Here

//            tx.begin();
            OQLQuery query = odmg.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

     * 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

Related Classes of org.odmg.DList

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.