Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.QueryResults


       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_LOCKED.ID as ID "
              + "from PTF_LOCKED order by PTF_LOCKED.ID "
              + "AS " + OID.class.getName());
        QueryResults results = query.execute(Database.READONLY);
       
        long result = System.currentTimeMillis();
       
        int count = 0;
        while (results.hasMore()) {
            OID oid = (OID) results.next();
            iterateStates((Locked) db.load(Locked.class, oid.getId(), Database.READONLY));

            count++;
        }
       
View Full Code Here


     */
    public void testAbsoluteA() throws PersistenceException {
        _db.begin();
        OQLQuery oqlquery = _db.getOQLQuery(
                "SELECT object FROM " + Entity.class.getName() + " object");
        QueryResults enumeration = oqlquery.execute(true);
        assertTrue("should have been able to move to 1", enumeration.absolute(1));
        assertTrue("should have been able to move to 5", enumeration.absolute(5));
        assertTrue("should have been able to move to 10", enumeration.absolute(10));
        assertTrue("should have been able to move to 15", enumeration.absolute(15));
        assertTrue("should have been able to move to 20", enumeration.absolute(20));
        assertTrue("should have been able to move to 25", enumeration.absolute(25));
        _db.commit();
    }
View Full Code Here

       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_LOCKED.ID as ID "
              + "from PTF_LOCKED order by PTF_LOCKED.ID "
              + "AS " + OID.class.getName());
        QueryResults results = query.execute(Database.READONLY);
       
        long result = System.currentTimeMillis();
       
        int count = 0;
        while (results.hasMore()) {
            results.next();
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
View Full Code Here

     */
    public void testAbsoluteB() throws PersistenceException {
        _db.begin();
        OQLQuery oqlquery = _db.getOQLQuery(
                "SELECT object FROM " + Entity.class.getName() + " object");
        QueryResults enumeration = oqlquery.execute(true);
        int next = 1;
        boolean hasMore = true;
        while (enumeration.hasMore() && hasMore) {
            LOG.debug("at: " + next);
            hasMore = enumeration.absolute(next);
            next++;
        }
        _db.commit();
    }
View Full Code Here

     */
    public void testAbsoluteC() throws PersistenceException {
        _db.begin();
        OQLQuery oqlquery = _db.getOQLQuery(
                "SELECT object FROM " + Entity.class.getName() + " object");
        QueryResults enumeration = oqlquery.execute(true);
        assertFalse("shouldn't be able to move to -50", enumeration.absolute(-50));
        assertFalse("shouldn't be able to move to 99999", enumeration.absolute(99999));
        _db.commit();
    }
View Full Code Here

    public void testAbsoluteD() {
        try {
            _db.begin();
            OQLQuery oqlquery = _db.getOQLQuery(
                    "SELECT object FROM " + Entity.class.getName() + " object");
            QueryResults enumeration = oqlquery.execute(false);
            // following should fail.
            enumeration.absolute(5);
            _db.commit();
            fail("Calling absolute on a non-scrollable resultset should fail");
        } catch (Exception ex) {
            assertTrue(true);
        }
View Full Code Here

    /**
     * Delete all objects in test data set.
     */
    private void deleteTestDataSet() {
        log("deleting test data set...");
        QueryResults enumeration;
        ManyGroup group = null;
        ManyPerson person = null;
        Database db = null;
        try {
            // select an group and delete it, if it exist!
            db = this._category.getDatabase();
            db.begin();
            OQLQuery oqlclean = db.getOQLQuery(
                    "SELECT object FROM " + ManyGroup.class.getName()
                    + " object WHERE object.id < $1");
            oqlclean.bind(Integer.MAX_VALUE);
            enumeration = oqlclean.execute();
            while (enumeration.hasMore()) {
                group = (ManyGroup) enumeration.next();
                _stream.println("Retrieved object: " + group);
                db.remove(group);
                _stream.println("Deleted object: " + group);
            }
            db.commit();

            db.begin();
            oqlclean = db.getOQLQuery(
                    "SELECT object FROM " + ManyPerson.class.getName()
                    + " object WHERE object.id < $1");
            oqlclean.bind(Integer.MAX_VALUE);
            enumeration = oqlclean.execute();
            while (enumeration.hasMore()) {
                person = (ManyPerson) enumeration.next();
                _stream.println("Retrieved object: " + person);
                db.remove(person);
                _stream.println("Deleted object: " + person);
            }
            db.commit();
View Full Code Here

        assertNotNull(db);
        db.begin();
        OQLQuery query = db.getOQLQuery("SELECT h FROM "
                + House.class.getName() + " h WHERE h.flats.id = $1");
        query.bind(2);
        QueryResults result = query.execute();
       
        House e = (House) result.next();
        assertEquals(101, e.getId());
        assertEquals(2, e.getFlats().length);
       
        result.close();
        db.commit();
        db.close();
    }
View Full Code Here

        Database db2 = _category.getDatabase();
        db2.begin();

        OQLQuery qry = db2.getOQLQuery(
                "SELECT o FROM " + Lazy1to1Book.class.getName() + " o");
        QueryResults results = qry.execute();
        assertTrue("Couldn't find the book in db: ", results.hasMore());

        Lazy1to1Book book = null;
        if (results.hasMore()) {
            book = (Lazy1to1Book) results.next();
            Lazy1to1Author currentAuthor = book.getAuthor();

            assertNotNull("book should have author", currentAuthor);
            assertNotNull("author should have a last name", currentAuthor.getLastName());
        }
View Full Code Here

        assertNotNull(db);
        db.begin();
        OQLQuery query = db.getOQLQuery("SELECT b FROM " + Book.class.getName()
                + " b WHERE b.title = $1");
        query.bind("Heart of Darkness");
        QueryResults result = query.execute();
       
        int count = 0;
        Book b = null;
        while (result.hasMore()) {
            b = (Book) result.next();
            count++;
        }
       
        assertEquals(1, count);
        assertEquals(1234, b.getIsbn());
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.