Package org.odmg

Examples of org.odmg.OQLQuery


        // 1.build complete OQL statement
        String oql = "select all from java.lang.Object where " + predicate;
        TransactionImpl tx = getTransaction();
        if (tx == null) throw new QueryInvalidException("Need running transaction to do query");

        OQLQuery predicateQuery = tx.getImplementation().newOQLQuery();
        predicateQuery.create(oql);
        Query pQ = ((OQLQueryImpl) predicateQuery).getQuery();
        Criteria pCrit = pQ.getCriteria();

        PBCapsule handle = new PBCapsule(pbKey, tx);
        DList result;
View Full Code Here


    {
        // 1.build complete OQL statement
        String oql = "select all from java.lang.Object where " + predicate;
        TransactionImpl tx = getTransaction();

        OQLQuery predicateQuery = tx.getImplementation().newOQLQuery();

        PBCapsule capsule = new PBCapsule(tx.getImplementation().getCurrentPBKey(), tx);
        PersistenceBroker broker = capsule.getBroker();

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

            Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
            // join selection of elements with predicate criteria:
View Full Code Here

        database.deletePersistent(s1);
        database.deletePersistent(d4);
        tx.commit();

        tx.begin();
        OQLQuery query = odmg.newOQLQuery();
        query.create("select shops from " + Shop.class.getName() + " where name like $1");
        query.bind(name + "%");
        Collection result = (Collection) query.execute();

        assertEquals(2, result.size());

        query = odmg.newOQLQuery();
        query.create("select shops from " + Distributor.class.getName() + " where name like $1");
        query.bind(name + "%");
        result = (Collection) query.execute();

        assertEquals(2, result.size());
        tx.commit();

        tx.begin();
        query = odmg.newOQLQuery();
        query.create("select shops from " + Distributor.class.getName() + " where name like $1");
        query.bind(name + "_3");
        result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        Distributor d3New = (Distributor) result.iterator().next();
View Full Code Here

        database.deletePersistent(s1);
        database.deletePersistent(d4);
        tx.commit();

        tx.begin();
        OQLQuery query = odmg.newOQLQuery();
        query.create("select shops from " + Shop.class.getName() + " where name like $1");
        query.bind(name + "%");
        Collection result = (Collection) query.execute();

        assertEquals(0, result.size());

        query = odmg.newOQLQuery();
        query.create("select shops from " + Distributor.class.getName() + " where name like $1");
        query.bind(name + "%");
        result = (Collection) query.execute();

        assertEquals(2, result.size());
        tx.commit();

        tx.begin();
        query = odmg.newOQLQuery();
        query.create("select shops from " + Distributor.class.getName() + " where name like $1");
        query.bind(name + "_3");
        result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        Distributor d3New = (Distributor) result.iterator().next();
View Full Code Here

        tx.commit();

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

        OQLQuery query = odmg.newOQLQuery();
        query.create("select products from " + Shop.class.getName() + " where name like $1");
        query.bind(name + "%");
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        Shop newShop = (Shop) result.iterator().next();
        assertNotNull(newShop.getProducts());
        assertEquals(2, newShop.getProducts().size());

        boolean match = false;
        for(Iterator iterator = newShop.getProducts().iterator(); iterator.hasNext();)
        {
            Product p =  (Product) iterator.next();
            if(p.getSubProducts() != null && p.getSubProducts().size() > 0)
            {
                match = true;
                assertEquals(3, p.getSubProducts().size());
            }
        }
        assertTrue("Sub products aren't stored", match);

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


        tx.begin();
        tx.getBroker().clearCache();
        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_subPro%");
        result = (Collection) query.execute();
        tx.commit();
        assertEquals(3, result.size());

        tx.begin();
        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_product_1");
        result = (Collection) query.execute();
        assertEquals(1, result.size());

        database.deletePersistent(result.iterator().next());
        tx.commit();


        tx.begin();
        tx.getBroker().clearCache();
        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_subPro%");
        result = (Collection) query.execute();
        tx.commit();
        assertEquals(3, result.size());
    }
View Full Code Here

        tx.commit();

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

        OQLQuery query = odmg.newOQLQuery();
        query.create("select products from " + Shop.class.getName() + " where name like $1");
        query.bind(name + "%");
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        Shop newShop = (Shop) result.iterator().next();
        assertNotNull(newShop.getProducts());
        assertEquals(2, newShop.getProducts().size());

        boolean match = false;
        for(Iterator iterator = newShop.getProducts().iterator(); iterator.hasNext();)
        {
            Product p =  (Product) iterator.next();
            if(p.getSubProducts() != null && p.getSubProducts().size() > 0)
            {
                match = true;
                assertEquals(3, p.getSubProducts().size());
            }
        }
        assertTrue("Sub products aren't stored", match);

        tx.begin();
        // now we enable cascading delete
        tx.setCascadingDelete(Shop.class, true);
        database.deletePersistent(s);
        tx.commit();


        tx.begin();
        tx.getBroker().clearCache();
        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_subPro%");
        result = (Collection) query.execute();
        assertEquals(3, result.size());

        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_product_1");
        result = (Collection) query.execute();
        assertEquals(0, result.size());

        tx.commit();
    }
View Full Code Here

        tx.commit();

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

        OQLQuery query = odmg.newOQLQuery();
        query.create("select products from " + Shop.class.getName() + " where name like $1");
        query.bind(name + "%");
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        Shop newShop = (Shop) result.iterator().next();
        assertNotNull(newShop.getProducts());
        assertEquals(2, newShop.getProducts().size());

        boolean match = false;
        for(Iterator iterator = newShop.getProducts().iterator(); iterator.hasNext();)
        {
            Product p =  (Product) iterator.next();
            if(p.getSubProducts() != null && p.getSubProducts().size() > 0)
            {
                match = true;
                assertEquals(3, p.getSubProducts().size());
            }
        }
        assertTrue("Sub products aren't stored", match);

        tx.begin();
        // now we enable cascading delete
        tx.setCascadingDelete(Shop.class, true);
        tx.setCascadingDelete(Product.class, true);
        database.deletePersistent(s);
        tx.commit();


        tx.begin();
        tx.getBroker().clearCache();
        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_subPro%");
        result = (Collection) query.execute();
        assertEquals(0, result.size());

        query = odmg.newOQLQuery();
        query.create("select products from " + Product.class.getName() + " where name like $1");
        query.bind(name + "_product_1");
        result = (Collection) query.execute();
        assertEquals(0, result.size());

        tx.commit();
    }
View Full Code Here

        tx.commit();

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

        OQLQuery query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        ShopDetail sdNew = (ShopDetail) result.iterator().next();
        assertNotNull(sdNew.getShop());

        tx.begin();
        database.deletePersistent(sdNew);
        tx.flush();

        query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();
        tx.commit();
        assertEquals(0, result.size());

        tx.begin();
        query = odmg.newOQLQuery();
        query.create("select detail from " + Shop.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();

        assertEquals(1, result.size());

        database.deletePersistent(result.iterator().next());
        tx.commit();
View Full Code Here

        database.makePersistent(sd);
        database.makePersistent(s);
        tx.commit();

        tx.begin();
        OQLQuery query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        ShopDetail sdNew = (ShopDetail) result.iterator().next();
        assertNotNull(sdNew.getShop());

        tx.begin();
        tx.setCascadingDelete(ShopDetail.class, true);
        database.deletePersistent(sdNew);
        database.makePersistent(sdNew);
        tx.flush();

        query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();
        tx.commit();
        assertEquals(1, result.size());

        tx.begin();
        database.deletePersistent(sdNew);
        database.makePersistent(sdNew);
        database.deletePersistent(sdNew);
        tx.flush();

        query = odmg.newOQLQuery();
        query.create("select detail from " + Shop.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();
        assertEquals(0, result.size());
        tx.commit();
    }
View Full Code Here

        tx.commit();

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

        OQLQuery query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        tx.commit();

        assertEquals(1, result.size());
        ShopDetail sdNew = (ShopDetail) result.iterator().next();
        assertNotNull(sdNew.getShop());

        tx.begin();
        tx.setCascadingDelete(ShopDetail.class, true);
        database.deletePersistent(sdNew);
        tx.flush();

        query = odmg.newOQLQuery();
        query.create("select detail from " + ShopDetail.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();
        tx.commit();
        assertEquals(0, result.size());

        tx.begin();
        query = odmg.newOQLQuery();
        query.create("select detail from " + Shop.class.getName() + " where name like $1");
        query.bind(name);
        result = (Collection) query.execute();
        assertEquals(0, result.size());
        tx.commit();
    }
View Full Code Here

TOP

Related Classes of org.odmg.OQLQuery

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.