Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.OQLQuery


     */
    protected void finalize() throws Throwable {
        if (_scope != null || !isActive()) { return; }
           
        // retrieve SQL bound to this Database instance
        OQLQuery oqlQuery = getOQLQuery();
        String sql = ((OQLQueryImpl) oqlQuery).getSQL();
       
        _log.warn(Messages.format("jdo.finalize_close", this.toString(), _dbName, sql));

        close();
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public OQLQuery getOQLQuery(final String oql) throws PersistenceException {
        OQLQuery oqlImpl;

        oqlImpl = new OQLQueryImpl(this);
        oqlImpl.create(oql);
        return oqlImpl;
    }
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();
View Full Code Here

     */
    public void testSelectQuery() throws Exception {
        Database db = _jdo.getDatabase();
        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();
View Full Code Here

        Database db = _category.getDatabase();
       
        // 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());
View Full Code Here

    public void testNonExistentNamedQuery() throws Exception {
        Database db = _category.getDatabase();
       
        // try to get non-existent named query
        db.begin();
        OQLQuery query = null;           
        try {
            query = db.getNamedQuery(SELECT_KNIGHTS_WHO_SAY_NI);
            fail("Database.getNamedQuery() should have thrown a QueryException");
        } catch (QueryException e) {
            //  great, this is what we expect
            //  check if it's the correct one
            if (!e.getMessage().startsWith("Cannot find a named query")) {
                throw e;
            }
        } finally {
            if (query != null) {
                query.close();
            }
        }
       
        db.commit();
        db.close();
View Full Code Here

        Database db = _category.getDatabase();
       
        // try to load non-existent named query
        db.begin();
        try {
            OQLQuery query = db.getNamedQuery(QUERY_WITH_BAD_SYNTAX);           
            query.close(); //this shouldn't happen
        } catch (QueryException e) {
            // great, this is what we expect
            // check if it's the correct one
            if (!e.getMessage().startsWith("Could not find class")) {
                throw e;
View Full Code Here

        Database db = _category.getDatabase();       
        // 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++;
View Full Code Here

        int count = 0;
       
        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++;
        }
       
View Full Code Here

        int count = 0;
       
        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++;
        }
       
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.