Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.Database


    }
   
    public void testReadOnlyCached() throws Exception {
        long start = System.currentTimeMillis();
       
        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(Database.READONLY);
       
        long result = System.currentTimeMillis();
       
        int count = 0;
        while (results.hasMore()) {
            results.next();
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadOnlyCached",
                         DF.format(begin - start),
View Full Code Here


       
        database.close();
    }
   
    public void testLoadComputer() throws Exception {
        Database database = _category.getDatabase();
       
        database.begin();
        Computer computer = (Computer) database.load(Computer.class, new Integer(2));
        database.commit();
       
        assertNotNull(computer);
        assertEquals("ctf.jdo.tc9x.Laptop", computer.getClass().getName());
        assertEquals(2, computer.getId());
        assertEquals("laptop 2", computer.getName());
       
        database.close();
    }
View Full Code Here

    }

    public void testReadWriteOidEmpty() throws Exception {
        long start = System.currentTimeMillis();
       
        Database db =  _jdo.getDatabase();
        db.getCacheManager().expireCache();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_SERVICE.ID as ID "
              + "from PTF_SERVICE order by PTF_SERVICE.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();
            db.load(Service.class, oid.getId());
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadWriteOidEmpty",
                         DF.format(begin - start),
View Full Code Here

       
        database.close();
    }
   
    public void testCreateAndLoadComputer() throws Exception {
        Database database = _category.getDatabase();

        database.begin();
        Order order = new Order();
        order.setId(12);
        order.setName("order 12");
        database.create(order);
        database.commit();

        database.begin();
        ProductDetail detail = new ProductDetail();
        detail.setId(12);
        detail.setCategory("category 12");
        detail.setLocation("location 12");
        database.create(detail);
        database.commit();
       
        database.begin();
        Laptop laptop = new Laptop();
        laptop.setId(12);
        laptop.setName("laptop 12");
        laptop.setCpu("centrino");
        laptop.setResolution("1600");
        laptop.setWeight(2450);
        laptop.setDetail((ProductDetail)
                database.load(ProductDetail.class, new Integer(12)));
        database.create(laptop);
        Collection orders = new LinkedList();
        orders.add(database.load(Order.class, new Integer(12)));
        laptop.setOrders(orders);
        database.commit();

        database.begin();
        Computer computer = (Computer) database.load(Computer.class, new Integer(12));
        database.commit();
       
        assertNotNull(computer);
        assertEquals("ctf.jdo.tc9x.Laptop", computer.getClass().getName());
        assertEquals(12, computer.getId());
        assertEquals("laptop 12", computer.getName());
       
        database.begin();
        computer = (Computer) database.load(Computer.class, new Integer(12));
        database.remove(computer);
        database.remove(database.load (ProductDetail.class, new Integer(12)));
        database.remove(database.load(Order.class, new Integer(12)));
        database.commit();
       
        database.close();
    }
View Full Code Here

    }
   
    public void testReadWriteOidCached() throws Exception {
        long start = System.currentTimeMillis();
       
        Database db =  _jdo.getDatabase();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_SERVICE.ID as ID "
              + "from PTF_SERVICE order by PTF_SERVICE.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();
            db.load(Service.class, oid.getId());
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadWriteOidCached",
                         DF.format(begin - start),
View Full Code Here

    }
   
    public void testReadOnlyOidEmpty() throws Exception {
        long start = System.currentTimeMillis();
       
        Database db =  _jdo.getDatabase();
        db.getCacheManager().expireCache();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_SERVICE.ID as ID "
              + "from PTF_SERVICE order by PTF_SERVICE.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();
            db.load(Service.class, oid.getId(), Database.READONLY);
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadOnlyOidEmpty",
                         DF.format(begin - start),
View Full Code Here

    }
   
    public void testReadOnlyOidCached() throws Exception {
        long start = System.currentTimeMillis();
       
        Database db =  _jdo.getDatabase();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_SERVICE.ID as ID "
              + "from PTF_SERVICE order by PTF_SERVICE.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();
            db.load(Service.class, oid.getId(), Database.READONLY);
            count++;
        }
       
        long iterate = System.currentTimeMillis();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadOnlyOidCached",
                         DF.format(begin - start),
View Full Code Here

    /**
     * Test method.
     * @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());
           
            List containerItems = container.getProp();
            assertNotNull(containerItems);
            assertTrue(containerItems.size() > 0);
            i++;
        }
        db.commit();
        db.close();
    }
View Full Code Here

    }
   
    public void testReadOnlyOidOnly() throws Exception {
        long start = System.currentTimeMillis();
       
        Database db =  _jdo.getDatabase();
        db.begin();
       
        long begin = System.currentTimeMillis();
       
        OQLQuery query = db.getOQLQuery(
                "CALL SQL select PTF_SERVICE.ID as ID "
              + "from PTF_SERVICE order by PTF_SERVICE.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();
       
        db.commit();
       
        long commit = System.currentTimeMillis();
       
        db.close();

        long close = System.currentTimeMillis();
       
        LOG.info(format("ReadOnlyOidOnly",
                         DF.format(begin - start),
View Full Code Here

       
        database.close();
    }

    public void testLoadComputerMulti() throws Exception {
        Database database = _category.getDatabase();
       
        database.begin();
        ComputerMulti computer = (LaptopMulti) database.load(ComputerMulti.class,
                new Identity(new Integer(1), new Integer(1)));
        database.commit();
       
        assertNotNull(computer);
        assertEquals(1, computer.getId1());
        assertEquals(1, computer.getId2());
        assertEquals("laptop 1", computer.getName());
       
        database.close();
    }
View Full Code Here

TOP

Related Classes of org.exolab.castor.jdo.Database

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.