Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.QueryResults


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


        _conn.close();
    }
   
    private void delete() throws PersistenceException {
        OQLQuery oql;
        QueryResults qres;
        int cnt;

        LOG.debug("Delete everything");
        _db.begin();
        oql = _db.getOQLQuery(
                "SELECT master FROM " + MasterKeyGen.class.getName() + " master");
        qres = oql.execute();

        for (cnt = 0; qres.hasMore(); cnt++) {
            _db.remove(qres.next());
        }
        LOG.debug("Deleting " + cnt + " master objects");

        oql = _db.getOQLQuery("SELECT group FROM " + Group.class.getName() + " group");
        qres = oql.execute();
        for (cnt = 0; qres.hasMore(); cnt++) {
            _db.remove(qres.nextElement());
        }
        LOG.debug("Deleting " + cnt + " group objects");
        _db.commit();
    }
View Full Code Here

    private void deleteGroups() throws PersistenceException {
        _db.begin();
        OQLQuery oqlclean = _db.getOQLQuery("SELECT object FROM "
                + ManyGroupKeyGen.class.getName() + " object WHERE object.id < $1");
        oqlclean.bind(Integer.MAX_VALUE);
        QueryResults enumeration = oqlclean.execute();
        while (enumeration.hasMore()) {
            _groupA = (ManyGroupKeyGen) enumeration.next();
            _stream.println("Retrieved object: " + _groupA);
            _db.remove(_groupA);
            _stream.println("Deleted object: " + _groupA);
        }
        _db.commit();
View Full Code Here

    private void deletePersons() throws PersistenceException {
        _db.begin();
        OQLQuery oqlclean = _db.getOQLQuery("SELECT object FROM "
                + ManyPersonKeyGen.class.getName() + " object WHERE object.id < $1");
        oqlclean.bind(Integer.MAX_VALUE);
        QueryResults enumeration = oqlclean.execute();
        while (enumeration.hasMore()) {
            _person1 = (ManyPersonKeyGen) enumeration.next();
            _stream.println("Retrieved object: " + _person1);
            _db.remove(_person1);
            _stream.println("Deleted object: " + _person1);
        }
        _db.commit();
View Full Code Here

        _db.begin();
        _oql.bind(_groupAId);
        _groupA = null;
        _person1 = null;
        _person2 = null;
        QueryResults enumeration = _oql.execute();
        if (enumeration.hasMore()) {
            _groupA = (ManyGroupKeyGen) enumeration.next();
            _stream.println("Retrieved object: " + _groupA);
            Collection p = _groupA.getPeople();
            if (p != null) {
                Iterator itor = p.iterator();
                if (itor.hasNext()) { _person1 = (ManyPersonKeyGen) itor.next(); }
View Full Code Here

        _db.begin();
        _oql.bind(_groupAId);
        _groupA = null;
        _person1 = null;
        _person2 = null;
        QueryResults enumeration = _oql.execute();
        if (enumeration.hasMore()) {
            _groupA = (ManyGroupKeyGen) enumeration.next();
            _stream.println("Retrieved object: " + _groupA);
            Collection p = _groupA.getPeople();
            if (p != null) {
                Iterator itor = p.iterator();
                if (itor.hasNext()) { _person1 = (ManyPersonKeyGen) itor.next(); }
View Full Code Here

        _db.begin();
        _oql.bind(_groupAId);
        _groupA = null;
        _person1 = null;
        _person2 = null;
        QueryResults enumeration = _oql.execute();
        if (enumeration.hasMore()) {
            _groupA = (ManyGroupKeyGen) enumeration.next();
            _stream.println("Retrieved object: " + _groupA);
            Collection p = _groupA.getPeople();
            if (p != null) {
                Iterator itor = p.iterator();
                if (itor.hasNext()) {
View Full Code Here

        db.close();
    }

    public void testOQL() throws PersistenceException {
        OQLQuery      oql;
        QueryResults  results;
        Database db = _category.getDatabase();
        db.begin();
        oql = db.getOQLQuery("SELECT a FROM "
                + SelfRelationFolder.class.getName() + " a");
        results = oql.execute();
        assertTrue(results.hasMore());
       
        int counter = 0;
        SelfRelationFolder f;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(1, f.getId().intValue());
        assertEquals("parent", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(2, f.getId().intValue());
        assertEquals("first child", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(3, f.getId().intValue());
        assertEquals("second child", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(5, f.getId().intValue());
        assertEquals("Test Folder", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(6, f.getId().intValue());
        assertEquals("Test Child", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(7, f.getId().intValue());
        assertEquals("Test Grandchild", f.getName());
        counter++;

        f = (SelfRelationFolder) results.next();
        assertNotNull(f);
        assertEquals(8, f.getId().intValue());
        assertEquals("Test Greatgrandchild", f.getName());
        counter++;
View Full Code Here

        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT entity FROM "
                + Entity.class.getName() + " entity WHERE id = $1");
        query.bind(new Integer(1));
        QueryResults results = query.execute();
       
        Entity entity = (Entity) results.next();

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

        db.begin();
       
        OQLQuery query = db.getOQLQuery("SELECT entity FROM "
                + AutostoreMainMany.class.getName() + " entity WHERE id = $1");
        query.bind(new Integer(1));
        QueryResults results = query.execute();
       
        AutostoreMainMany entity = (AutostoreMainMany) results.next();

        assertNotNull(entity);
        assertEquals(new Integer(1), entity.getId());
       
        List associatedManys = entity.getAssociatedMany();
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.