Package org.exolab.castor.jdo

Examples of org.exolab.castor.jdo.Database


    }

    public void testLoadChild() throws Exception {
        Lazy1to1Child child = null;

        Database db = _category.getDatabase();

        db.begin();
        child = (Lazy1to1Child) db.load(Lazy1to1Child.class, new Integer (1));
        assertChild(child, 1, "child 1");
        db.commit();
       
        db.close();
    }
View Full Code Here


    }

    public void testLoadChildReadOnly() throws Exception {
        Lazy1to1Child child = null;

        Database db = _category.getDatabase();

        db.begin();
        child = (Lazy1to1Child) db.load(Lazy1to1Child.class, new Integer (1),
                                        AccessMode.ReadOnly);
        assertChild(child, 1, "child 1");
        db.commit();
       
        db.close();
    }
View Full Code Here

    }

    public void testLoadParentWhereChildIsNull() throws Exception {
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (5));
        assertParent(parent, 5, "parent 5");
        assertNull(parent.getChild());
        db.commit();
       
        db.close();
    }
View Full Code Here

    }

    public void testLoadParentWithAccess() throws Exception {
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        db.commit();

        assertParent(parent, 1, "parent 1");
        Lazy1to1Child nature = parent.getChild();
        assertChild(nature, 1, "child 1");

        db.close();
    }
View Full Code Here

    }

    public void testLoadParentReadOnlyWithAccessWithoutChange() throws Exception {
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1),
                                          AccessMode.ReadOnly);
        db.commit();

        assertParent(parent, 1, "parent 1");
        Lazy1to1Child nature = parent.getChild();
        assertChild(nature, 1, "child 1");

        // re-load to assert that nothing has changed
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        db.commit();

        assertParent(parent, 1, "parent 1");
        assertChild(parent.getChild(), 1, "child 1");

        db.close();
    }
View Full Code Here

    }

    public void testLoadParentReadOnlyWithAccessWithChange() throws Exception {
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1),
                                          AccessMode.ReadOnly);

        assertParent(parent, 1, "parent 1");
        Lazy1to1Child nature = parent.getChild();
        assertChild(nature, 1, "child 1");

        parent.getChild().setDescription("child changed");

        db.commit();

        // re-load to assert that nothing has changed
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        db.rollback();

        assertParent(parent, 1, "parent 1");
        assertChild(parent.getChild(), 1, "child 1");

        db.close();
    }
View Full Code Here

    }

    public void testLoadParentWithoutAccess() throws Exception {
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        assertParent(parent, 1, "parent 1");
        db.commit();
       
        db.close();
    }
View Full Code Here

    public void testLoadParentReadOnlyWithoutAccess() throws Exception {
       
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1),
                                          AccessMode.ReadOnly);
        assertParent(parent, 1, "parent 1");
        db.commit();
       
        db.close();
    }
View Full Code Here

    public void testSerializeParentWithAccess () throws Exception {
        File file = new File ("serialized.out");
        ObjectOutputStream out = new ObjectOutputStream (new FileOutputStream (file));
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        assertParent(parent, 1, "parent 1");
        assertChild(parent.getChild(), 1, "child 1");
        db.commit();
       
        out.writeObject (parent);
        out.close();

        ObjectInputStream in = new ObjectInputStream (new FileInputStream (file));
        Lazy1to1Parent accountDeserialized = (Lazy1to1Parent) in.readObject ();
        assertNotNull(accountDeserialized);
        assertEquals(1, accountDeserialized.getId().intValue());
        assertChild(accountDeserialized.getChild(), 1, "child 1");
       
        db.close();
    }
View Full Code Here

        File file = new File("serialized.out");
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream (file));
       
        Lazy1to1Parent parent = null;
       
        Database db = _category.getDatabase();
       
        db.begin();
        parent = (Lazy1to1Parent) db.load(Lazy1to1Parent.class, new Integer (1));
        assertParent (parent, 1, "parent 1");
        db.commit();
       
        out.writeObject (parent);
        out.close();
       
        ObjectInputStream in = new ObjectInputStream(new FileInputStream (file));
        parent = (Lazy1to1Parent) in.readObject ();
        assertNotNull(parent);
        assertEquals(1, parent.getId().intValue());
        assertChild(parent.getChild(), 1, "child 1");
       
        db.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.