Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.Database.begin()


    public void testCreateLoadUpdateDelete() throws Exception {
        Database database;
       
        // create product
        database = _category.getDatabase();
        database.begin();
       
        Product pc = new Product(1, "LCD", KindEnum.MONITOR);
        database.create(pc);

        database.commit();
View Full Code Here


        database.commit();
        database.close();

        // load created product
        database = _category.getDatabase();
        database.begin();
       
        Product pl1 = new Product(1, "LCD", KindEnum.MONITOR);
        Product pl2 = (Product) database.load(Product.class, new Integer(1));
        assertEquals(pl1, pl2);
View Full Code Here

        database.commit();
        database.close();

        // update product
        database = _category.getDatabase();
        database.begin();
       
        Product pu = (Product) database.load(Product.class, new Integer(1));
        pu.setName("Laser");
        pu.setKind(KindEnum.PRINTER);
View Full Code Here

        database.commit();
        database.close();

        // load updated product
        database = _category.getDatabase();
        database.begin();
       
        Product pl3 = new Product(1, "Laser", KindEnum.PRINTER);
        Product pl4 = (Product) database.load(Product.class, new Integer(1));
        assertEquals(pl3, pl4);
View Full Code Here

        database.commit();
        database.close();

        // delete product
        database = _category.getDatabase();
        database.begin();
       
        Product pd = (Product) database.load(Product.class, new Integer(1));
        database.remove(pd);

        database.commit();
View Full Code Here

    public void testQuery() throws Exception {
        Database database;
       
        // create some products
        database = _category.getDatabase();
        database.begin();
       
        database.create(new Product(1, "LCD", KindEnum.MONITOR));
        database.create(new Product(2, "Laser", KindEnum.PRINTER));
        database.create(new Product(3, "Desktop", KindEnum.COMPUTER));
        database.create(new Product(4, "Notebook", KindEnum.COMPUTER));
View Full Code Here

        database.commit();
        database.close();

        // query and delete all product
        database = _category.getDatabase();
        database.begin();
       
        Product pq;
        OQLQuery query = database.getOQLQuery("select p from "
                + ctf.jdo.tc8x.Product.class.getName() + " p order by p.id");
        QueryResults results = query.execute();
View Full Code Here

     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testQueryEntityOne() throws Exception {
        Database db = _category.getDatabase();
        db.begin();
       
        Parent entity = (Parent) db.load(Parent.class, new Integer(1));

        assertNotNull(entity);
        assertEquals(new Integer(1), entity.getId());
View Full Code Here

     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testLoadChild() throws Exception {
        Database db = _category.getDatabase();
        db.begin();
       
        Child child = (Child) db.load(Child.class, new Integer(1));

        assertNotNull(child);
        assertEquals(new Integer(1), child.getId());
View Full Code Here

     * Test method.
     * @throws Exception For any exception thrown.
     */
    public void testLoadEntityWithCompoundId() throws Exception {
        Database db = _category.getDatabase();
        db.begin();
       
        ParentWithCompoundId child = (ParentWithCompoundId)
            db.load(ParentWithCompoundId.class,
                    new Identity(new Integer(1), new Integer(1)));

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.