Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.QueryResults


     */
    private void testDirtyIgnored(final AccessMode accessMode)
    throws PersistenceException, SQLException {
        OQLQuery      oql;
        Sample    object;
        QueryResults   enumeration;

        // Open transaction in order to perform JDO operations
        _db.begin();
   
        // Determine if test object exists, if not create it.
        // If it exists, set the name to some predefined value
        // that this test will later override.
        oql = _db.getOQLQuery("SELECT object FROM "
                + Sample.class.getName() + " object WHERE id = $1");
        oql.bind(Sample.DEFAULT_ID);
       
        enumeration = oql.execute();
        if (enumeration.hasMore()) {
            object = (Sample) enumeration.next();
            LOG.debug("Retrieved object: " + object);
            object.setValue1(Sample.DEFAULT_VALUE_1);
            object.setValue2(Sample.DEFAULT_VALUE_2);
        } else {
            object = new Sample();
View Full Code Here


                + Entity.class.getName() + " t order by id limit $1 offset $2");

        query.bind(LIMIT);
        query.bind(OFFSET);

        QueryResults results = query.execute();
        assertNotNull (results);
        // size() not available using an Oracle DB assertEquals (LIMIT, results.size());
        for (int i = 1 + OFFSET; i <= OFFSET + LIMIT; i++) {
            Entity testObject = (Entity) results.next();
            assertEquals(i, testObject.getId());
        }
        assertTrue(!results.hasMore());

        getDatabase().commit();
    }
View Full Code Here

    public final void testLimit() throws PersistenceException {
        _db.begin();
        OQLQuery query = _db.getOQLQuery(
                "select t from " + Entity.class.getName() + " t order by id limit $1");
        query.bind(LIMIT);
        QueryResults results = query.execute();
        assertNotNull(results);
        // size() not available using an Oracle DB assertEquals (LIMIT, results.size());
        for (int i = 1; i <= LIMIT; i++) {
            Entity testObject = (Entity) results.next();
            assertEquals(i, testObject.getId());
        }
        assertTrue(!results.hasMore());

        _db.commit();
    }
View Full Code Here

        Database database = _category.getDatabase();
       
        database.begin();
        OQLQuery query = database.getOQLQuery("select owner from "
                + Owner.class.getName() + " as owner");
        QueryResults results = query.execute();
       
        if (results.hasMore()) {
            int counter = 1;
            while (results.hasMore()) {
                Owner owner = (Owner) results.next();
                assertNotNull(owner);
                assertEquals(counter, owner.getId().intValue());
               
                counter += 1;
            }
View Full Code Here

       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = _db.getOQLQuery(
                "SELECT o FROM " + Locked.class.getName() + " o order by o.id");
        QueryResults results = query.execute();
       
        long result = System.currentTimeMillis();
       
        initIterateQueries();

        int count = 0;
        while (results.hasMore()) {
            iterateStates((Locked) results.next(), Database.SHARED);

            count++;
        }
       
        long iterate = System.currentTimeMillis();
View Full Code Here

       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = _db.getOQLQuery(
                "SELECT o FROM " + Locked.class.getName() + " o order by o.id");
        QueryResults results = query.execute();
       
        long result = System.currentTimeMillis();
       
        initIterateQueries();

        int count = 0;
        while (results.hasMore()) {
            iterateStates((Locked) results.next(), Database.SHARED);

            count++;
        }
       
        long iterate = System.currentTimeMillis();
View Full Code Here

        Database database = _category.getDatabase();
       
        database.begin();
        OQLQuery query = database.getOQLQuery("select computer from "
                + Computer.class.getName() + " as computer order by computer.id");
        QueryResults results = query.execute();
       
        if (results.hasMore()) {
            int counter = 1;
            while (results.hasMore()) {
                Computer computer = (Computer) results.next();
                assertNotNull(computer);
                assertEquals(counter, computer.getId());
                assertEquals(classNames[counter - 1], computer.getClass().getName());
               
                counter += 1;
View Full Code Here

                + Entity.class.getName() + " t order by id limit $1 offset $2");

        query.bind(LIMIT);
        query.bind(OFFSET);

        QueryResults results = query.execute();
        assertNotNull (results);
        /*size() not available using an Oracle DB
        assertEquals (LIMIT, results.size()); */
        for (int i = 1 + OFFSET; i <= OFFSET + LIMIT; i++) {
            Entity testObject = (Entity) results.next();
            assertEquals(i, testObject.getId());
        }
        assertTrue(!results.hasMore());

        getDatabase().commit();
    }
View Full Code Here

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

        Database database = _category.getDatabase();
       
        database.begin();
        OQLQuery query = database.getOQLQuery("select l from "
                + Laptop.class.getName() + " as l order by l.id");
        QueryResults results = query.execute();
       
        if (results.hasMore()) {
            int counter = 1;
            Laptop laptop = null;
            while (results.hasMore()) {
                laptop = (Laptop) results.next();
                assertNotNull(laptop);
                assertEquals(counter, laptop.getId());
               
                counter += 1;
            }
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.