Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.QueryResults


        Date loadDate = df.parse("2004-04-26");

        String oql = "select t from " + Entity.class.getName() + " t " + " where t.loadDate=$1";
        Query qry = db.getOQLQuery(oql);
        qry.bind(loadDate);
        QueryResults qrs = qry.execute(AccessMode.ReadOnly);
        while (qrs.hasMore()) {
            Entity entity = (Entity) qrs.next();
            if (LOG.isTraceEnabled()) { LOG.trace(entity); }
        }
       
        db.commit();
        db.close();
View Full Code Here


       
        // load all EntityOne instances using a named query
        db.begin();
       
        OQLQuery query = db.getNamedQuery(SELECT_ALL_ENTITY_ONE);       
        QueryResults results = query.execute();
        int i = 0;
        while (results.hasMore()) {
            NQEntity entity = (NQEntity) results.next();
            assertNotNull(entity);
            i++;
        }
        assertTrue(i >= ENTITY_COUNT);
        db.commit();
       
        // load EntityOne with Id=1 from persistent store
        db.begin();
       
        query = db.getNamedQuery(SELECT_ENTITY_ONE_BY_ID);
        query.bind(new Integer(0));
        results = query.execute();
       
        NQEntity entity = (NQEntity) results.next();

        assertNotNull(entity);
        assertEquals(new Integer(0), entity.getId());
       
        db.commit();
View Full Code Here

        // load all EntityOne instances using a named query
        // and then use same query but with hints
        db.begin();
       
        OQLQuery query = db.getNamedQuery(SELECT_ALL_ENTITY_ONE);       
        QueryResults results = query.execute();
        int countFirst = 0;
        while (results.hasMore()) {
            NQEntity entity = (NQEntity) results.next();
            assertNotNull(entity);
            countFirst++;
        }
        query = db.getNamedQuery(SELECT_ALL_ENTITY_HINT);       
        results = query.execute();
        int countSecond = 0;
        while (results.hasMore()) {
            NQEntity entity = (NQEntity) results.next();
            assertNotNull(entity);
            countSecond++;
        }
        assertEquals(countFirst, countSecond);
       
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + State.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + Department.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + Reason.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

        _db = _category.getDatabase();
    }

    public void runTest() throws PersistenceException {
        OQLQuery         oql;
        QueryResults     results;
        NestedObject     t;

        // Open transaction in order to perform JDO operations
        _db.begin();
        oql = _db.getOQLQuery("SELECT t FROM "
                + NestedObject.class.getName() + " t WHERE id = $1");
        oql.bind(NestedObject.DEFAULT_ID);
        results = oql.execute();
        if (results.hasMore()) {
            t = (NestedObject) results.next();
            _db.remove(t);
            LOG.debug("Deleting object: " + t);
        }
        _db.commit();
       
        _db.begin();
        t = new NestedObject();
        LOG.debug("Creating new object: " + t);
        _db.create(t);
        _db.commit();
       
        _db.begin();
        oql.bind(NestedObject.DEFAULT_ID);
        results = oql.execute();
        if (results.hasMore()) {
            t = (NestedObject) results.next();
            String nv1 = t.getNested1().getValue1();
            String nv2 = t.getNested2().getNested3().getValue2();
            if (NestedObject.DEFAULT_VALUE1.equals(nv1)
                    && NestedObject.DEFAULT_VALUE2.equals(nv2)) {
               
                LOG.debug("OK: Created object: " + t);
            } else {
                LOG.error("Creating object: " + t);
                fail("Creating object failed");
            }
        }
        _db.commit();
        oql.close();

        LOG.info("Testing nested fields in OQLQuery...");
        _db.begin();
        oql = _db.getOQLQuery("SELECT t FROM "
                + NestedObject.class.getName()
                + " t WHERE nested2.nested3.value2 = $1");
        oql.bind(NestedObject.DEFAULT_VALUE2);
        results = oql.execute();
        if (results.hasMore()) {
            LOG.info("OK: Nested fields persisted");
        } else {
            LOG.error("Failed to persist nested fields");
            fail("Failed to persist nested fields");
        }
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + Supplier.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + Type.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT o FROM "
                                      + Equipment.class.getName() + " o");
        QueryResults results = query.execute();
        while (results.hasMore()) {
            db.remove(results.next());
            count++;
        }
       
        db.commit();
        db.close();
View Full Code Here

TOP

Related Classes of org.exolab.castor.jdo.QueryResults

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.