Examples of OQLQuery


Examples of org.exolab.castor.jdo.OQLQuery

            performQuery();
        }

        public void performQuery() {

            OQLQuery oql;
            QueryResults r;

            boolean firstObject = true;
            Object o;
            Vector properties = null;
            _model = new DefaultTableModel();

            try {
                _statusBar.setText("performing Query");
                // clear results
                clearTabs();

                //ResultScrollpane.getViewport().remove(
                //    ResultScrollpane.getViewport().getComponent(0));
                // create a new conec
                Database db = _jdo.getDatabase();
                db.begin();

                 /**
                    * add query to the history,
                    * maybe it's important lo loglso querys that won't work
                    * for this reason it's logged before creation
                    */
                _qhistory.addQuery(_oqlquery.getText());


                oql = db.getOQLQuery(_oqlquery.getText());


                // and execute it
                Date starttime = new Date();
                r = oql.execute(Database.READONLY);
                Date endtime = new Date();
                // write the status bar
                _statusBar.setText("Query successful, Time: "
                        + (endtime.getTime() - starttime.getTime()) + " ms");

View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

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

Examples of org.exolab.castor.jdo.OQLQuery

       
        // Open transaction in order to perform JDO operations
        _db.begin();
       
        // Create two objects in the database -- need something to lock
        OQLQuery oql = _db.getOQLQuery("SELECT object FROM "
                + Sample.class.getName() + " object WHERE id = $1");
        oql.bind(Sample.DEFAULT_ID);

        enumeration = oql.execute();
        if (enumeration.hasMoreElements()) {
            object = (Sample) enumeration.nextElement();
            LOG.debug("Retrieved object: " + object);
            object.setValue1(Sample.DEFAULT_VALUE_1);
            object.setValue2(Sample.DEFAULT_VALUE_2);
        } else {
            object = new Sample();
            LOG.debug("Creating new object: " + object);
            _db.create(object);
        }
       
        oql.bind(Sample.DEFAULT_ID + 1);
       
        enumeration = oql.execute();
        if (enumeration.hasMoreElements()) {
            object = (Sample) enumeration.nextElement();
            LOG.debug("Retrieved object: " + object);
            object.setValue1(Sample.DEFAULT_VALUE_1);
            object.setValue2(Sample.DEFAULT_VALUE_2);
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

    public void runTest() throws Exception {
        testOQL();
    }

    public void testOQL() throws Exception {
        OQLQuery            oql;
        QueryResults        enumeration;
        UserTransaction     ut;
       
        try {  
            //obtain the UserTransaction from JNDI
            //this has been created in the JDOJ2EECategory
            ut = (UserTransaction) _context.lookup("java:/UserTransaction");
            //begin the transaction
            ut.begin();
            //get database - this should be bound to the transaction above
            _db = _category.getDatabase(_verbose);
            //execute some test OQL
            oql = _db.getOQLQuery(
                    "SELECT master FROM " + Master.class.getName() + " master");   
            enumeration = oql.execute();
            while (enumeration.hasMore()) { enumeration.next(); }
            //commit the transaction
            ut.commit();
        } catch (TransactionNotInProgressException e) {
            LOG.error (e.getClass().getName(), e);
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

    }

    public void runTest() throws PersistenceException, SQLException {
        _db.begin();
       
        OQLQuery query = _db.getOQLQuery(
                "select o from " + Sample.class.getName() + " o");
        QueryResults result = query.execute();
        while (result.hasMore()) { _db.remove(result.next()); }
        result.close();
        _db.commit();
       
        _synchronizables.clear();
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

        return _thread;
    }

    public void runOnce(final int cachetype) throws Exception {
        Enumeration     enumeration;
        OQLQuery        oql;

        // clear the table
        int del = _conn.createStatement().executeUpdate(
                "DELETE FROM tc0x_race");
        LOG.debug("row deleted in table core_race: " + del);
        _conn.commit();

        // create pairs of number
        _masterDB.begin();
       
        Race[] jdos = new Race[NUM_OF_VALUE_PAIRS];
        RaceSync[] controls = new RaceSync[NUM_OF_VALUE_PAIRS];
        switch (cachetype) {
        case 0:
            _classType = ctf.jdo.tc0x.RaceCount.class;
            _className = _classType.getName();
            for (int i = 0; i < jdos.length; i++) {
                jdos[i] = new RaceCount();
                jdos[i].setId(i);
                _masterDB.create(jdos[i]);
               
                controls[i] = new RaceSync();
            }
            break;
        case 1:
            _classType = ctf.jdo.tc0x.RaceTime.class;
            _className = _classType.getName();
            for (int i = 0; i < jdos.length; i++) {
                jdos[i] = new RaceTime();
                jdos[i].setId(i);
                _masterDB.create(jdos[i]);
               
                controls[i] = new RaceSync();
            }
            break;
        case 2:
            _classType = ctf.jdo.tc0x.RaceNone.class;
            _className = _classType.getName();
            for (int i = 0; i < jdos.length; i++) {
                jdos[i] = new RaceNone();
                jdos[i].setId(i);
                _masterDB.create(jdos[i]);
               
                controls[i] = new RaceSync();
            }
            break;
        case 3:
            _classType = ctf.jdo.tc0x.RaceUnlimited.class;
            _className = _classType.getName();
            for (int i = 0; i < jdos.length; i++) {
                jdos[i] = new RaceUnlimited();
                jdos[i].setId(i);
                _masterDB.create(jdos[i]);
               
                controls[i] = new RaceSync();
            }
            break;
        default:
            LOG.error("Unknown cache type");
        }

        _masterDB.commit();

        // create threads, make a race so each thread
        // keeping increment to the pairs of number.
        RaceThread[] ts = new RaceThread[NUM_OF_RACING_THREADS];

        for (int i = 0; i < ts.length; i++) {
            ts[i] = new RaceThread(this, _dbForRace[i], controls, NUM_OF_TRIALS);
            ts[i].start();
        }

        // wait till everybody done
        boolean isAllDone = false;
        int num;
        while (!isAllDone) {
            Thread.sleep(1000);
            num = 0;
            for (int i = 0; i < ts.length; i++) {
                if (ts[i].isDone()) {
                    num++;
                }
            }
            if (num == ts.length) {
                isAllDone = true;
            }
        }

        // see if their sum agree
        _masterDB.begin();
       
        num = 0;
        for (int i = 0; i < jdos.length; i++) {
            oql = _masterDB.getOQLQuery("SELECT object FROM " + _className
                    + " object WHERE id = $1");
            oql.bind(i);
            enumeration = oql.execute();
            if (enumeration.hasMoreElements()) {
                Race tr = (Race) enumeration.nextElement();
                if (tr.getValue1() == controls[i].getValue1()) { num++; }
                LOG.debug("Number Pair " + i + " -- JDO: "
                        + tr.getValue1() + " control: "
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

     * @throws Exception For any exception thrown.
     */
    public void testQueryEntityOne() throws Exception {
        Database db = _category.getDatabase();
        db.begin();
        OQLQuery aquery = db.getOQLQuery(
                "SELECT c FROM " + Container.class.getName() + " c");
        QueryResults aresults = aquery.execute();
        int i = 1;
        while (aresults.hasMore()) {
            Container container = (Container) aresults.next();
            assertNotNull(container);
            assertEquals(new Integer(i), container.getId());
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

        db.getCacheManager().expireCache();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "SELECT o FROM " + Service.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

Examples of org.exolab.castor.jdo.OQLQuery

        }
       
        private boolean process(final int i) throws Exception {
            if ((i % 4) == 0) {
                _db.begin();
                OQLQuery oql = _db.getOQLQuery("SELECT object FROM "
                        + _className + " object WHERE id = $1");
                oql.bind(i);
                QueryResults enumeration = oql.execute();
                if (enumeration.hasMore()) {
                    Race tr = (Race) enumeration.next();
                    tr.incValue1();
                    _db.commit();
                    return true;
                }
                LOG.error("Error: element not found!! missed in cache?\n");
                rollback(_db);
                throw new NoSuchElementException("No element found (a).");
            } else if ((i % 4) == 1) {
                _db.begin();
                OQLQuery oql = _db.getOQLQuery("SELECT object FROM "
                        + _className + " object WHERE id = $1");
                oql.bind(i);
                Enumeration enumeration = oql.execute();
                if (enumeration.hasMoreElements()) {
                    Race tr = (Race) enumeration.nextElement();
                    tr.incValue1();
                    _db.commit();
                    return true;
View Full Code Here

Examples of org.exolab.castor.jdo.OQLQuery

        Database db =  _jdo.getDatabase();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "SELECT o FROM " + Service.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
TOP
Copyright © 2018 www.massapi.com. 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.