Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.OQLQuery


     * implemention because it internally moves the cursor and then
     * moves it back.
     */
    public final void testSizeB() throws PersistenceException {
        _db.begin();
        OQLQuery oqlquery = _db.getOQLQuery(
                "SELECT object FROM " + Entity.class.getName() + " object");
        QueryResults enumeration = oqlquery.execute(true);
        while (enumeration.hasMore()) {
            enumeration.next();
            assertTrue("size should be > 0", enumeration.size() > 0);
            assertEquals("size should be ==25", enumeration.size(), 25);
        }
View Full Code Here


    /**
     * Does size return the right results?
     */
    public final void testSizeC() throws PersistenceException {
        _db.begin();
        OQLQuery oqlquery = _db.getOQLQuery(
                "SELECT object FROM " + Entity.class.getName() + " object");
        QueryResults enumeration = oqlquery.execute(true);
        int expectedSize = enumeration.size();
        int realSize = 0;
        while (enumeration.hasMore()) {
            enumeration.next();
            realSize++;
View Full Code Here

     * Get a JDO database
     */
    public void setUp() throws PersistenceException, SQLException { }

    public void runTest() throws PersistenceException, SQLException {
        OQLQuery              oql;
        TimeStampableObject   object;
        QueryResults          enumeration;

        // Remove and create the object
        _db = _category.getDatabase();
        _db.begin();
        oql = _db.getOQLQuery("select obj from "
                + TimeStampableObject.class.getName() + " obj");
        enumeration = oql.execute();
        if (enumeration.hasMore()) {
            object = (TimeStampableObject) enumeration.next();
            LOG.debug("Removing object: " + object);
            _db.remove(object);
        }
        _db.commit();
        oql.close();
        _db.close();
       
        _db = _category.getDatabase();
        _db.begin();
        object = new TimeStampableObject();
        LOG.debug("Creating new object: " + object);
        _db.create(object);
        _db.commit();
        _db.close();

        LOG.debug("Object timestamp: " + object.jdoGetTimeStamp());


        // Load the object
        _db = _category.getDatabase();
        _db.begin();
        oql = _db.getOQLQuery("select obj from "
                + TimeStampableObject.class.getName() + " obj");
        enumeration = oql.execute();

        if (enumeration.hasMore()) {
            object = (TimeStampableObject) enumeration.next();
            LOG.debug("Loaded object: " + object);
        }
        _db.rollback();
        oql.close();
        _db.close();

        // Change an attribute on the TestObject2
        object.setValue2("changed value");
        LOG.debug("Changed object: " + object);
View Full Code Here

     * Should fail with a non scrollable resultset.
     */
    public void testSizeD() {
        try {
            _db.begin();
            OQLQuery oqlquery = _db.getOQLQuery(
                    "SELECT object FROM " + Entity.class.getName() + " object");
            oqlquery.execute(false);
            _db.commit();
            // This test fails when executed against PostgreSQL.
            fail ("Calling size() on a non-scrollable ResultSet should fail.");
        } catch (Exception ex) {
            assertTrue(true);
View Full Code Here

     * For each key generator we have a pair of classes: TestXXXObject and
     * TestXXXExtends which use key generator XXX.
     */
    protected void testOneKeyGen(final Class objClass, final Class extClass)
    throws Exception {
        OQLQuery oql;
        UuidObject object;
        UuidObject ext;
        QueryResults enumeration;
       
        // Open transaction in order to perform JDO operations
        _db.begin();

        // Create first object
        object = (UuidObject) objClass.newInstance();
        LOG.debug("Creating first object: " + object);
        _db.create(object);
        LOG.debug("Created first object: " + object);

        // Create second object
        ext = (UuidObject) extClass.newInstance();
        LOG.debug("Creating second object: " + ext);
        _db.create(ext);
        LOG.debug("Created second object: " + ext);

        _db.commit();

        _db.begin();

        // Find the first object and remove it
        //object = (TestUuidObject) _db.load( objClass, object.getId() );
        oql = _db.getOQLQuery();
        oql.create("SELECT object FROM " + objClass.getName()
                + " object WHERE id = $1");
        oql.bind(object.getId());
        enumeration = oql.execute();
        LOG.debug("Removing first object: " + object);
        if (enumeration.hasMore()) {
            object = (UuidObject) enumeration.next();
            _db.remove(object);
            LOG.debug("OK: Removed");
        } else {
            LOG.error("first object not found");
            fail("first object not found");
        }

        // Find the second object and remove it
        //ext = (TestUuidObject) _db.load( extClass, ext.getId() );
        oql = _db.getOQLQuery();
        oql.create("SELECT ext FROM " + extClass.getName()
                + " ext WHERE id = $1");
        oql.bind(ext.getId());
        enumeration = oql.execute();
        LOG.debug("Removing second object: " + ext);
        if (enumeration.hasMore()) {
            ext = (UuidObject) enumeration.next();
            _db.remove(ext);
            LOG.debug("OK: Removed");
View Full Code Here

        db.getCacheManager().expireCache();
        db.begin();
       
        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();
       
        int count = 0;
        while (results.hasMore()) {
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        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();
       
        int count = 0;
        while (results.hasMore()) {
View Full Code Here

        db.getCacheManager().expireCache();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "SELECT o FROM " + Locked.class.getName() + " o order by o.id");
        QueryResults results = query.execute(Database.READONLY);
       
        long result = System.currentTimeMillis();
       
        int count = 0;
        while (results.hasMore()) {
View Full Code Here

        Database db = _jdo.getDatabase();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "SELECT o FROM " + Locked.class.getName() + " o order by o.id");
        QueryResults results = query.execute(Database.READONLY);
       
        long result = System.currentTimeMillis();
       
        int count = 0;
        while (results.hasMore()) {
View Full Code Here

        db.getCacheManager().expireCache();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        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()) {
View Full Code Here

TOP

Related Classes of org.exolab.castor.jdo.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.