Package org.odmg

Examples of org.odmg.Implementation


        obj_1.setSingleReference(s_ref_3);
        s_ref_3.setMainObject(obj_1);
        obj_2.setSingleReference(s_ref_4);
        s_ref_3.setMainObject(obj_1);

        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);

        Transaction tx = odmg.newTransaction();
        tx.begin();
        db.makePersistent(s_ref_1);
        db.makePersistent(s_ref_2);
        db.makePersistent(s_ref_3);
        db.makePersistent(s_ref_4);
View Full Code Here


     *
     * @param product The product to store
     */
    public static void storeProduct(Product product)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx   = impl.newTransaction();

        tx.begin();
        tx.lock(product, Transaction.WRITE);
        tx.commit();
    }
View Full Code Here

     * @param name The name of the product
     * @return The product if found
     */
    public static Product findProductByName(String name) throws Exception
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx   = impl.newTransaction();

        tx.begin();

        OQLQuery query = impl.newOQLQuery();

        query.create("select products from " + Product.class.getName() + " where name = $1");
        query.bind(name);

        DList   results = (DList)query.execute();
View Full Code Here

     * @param product The product to sell
     * @param number  The number of items to sell
     */
    public static void sellProduct(Product product, int number)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx   = impl.newTransaction();

        tx.begin();

        tx.lock(product, Transaction.WRITE);
        product.setStock(product.getStock() -  number);
View Full Code Here

     *
     * @param product The product to delete
     */
    public static void deleteProduct(Product product)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx = impl.newTransaction();

        tx.begin();

        Database db = impl.getDatabase(product);

        db.deletePersistent(product);

        tx.commit();
    }
View Full Code Here

     *
     * @param product The product to update in the database
     */
    public static void persistChanges(Product product)
    {
        Implementation impl = OJB.getInstance();
        TransactionExt tx  = (TransactionExt)impl.newTransaction();

        tx.begin();
        tx.markDirty(product);
        tx.commit();
    }
View Full Code Here

     *
     * @param args The commandline arguments
     */
    public static void main(String[] args) throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database       db   = odmg.newDatabase();

        db.open("default", Database.OPEN_READ_WRITE);

        Product product = new Product();

View Full Code Here

    {
        // get facade instance
        // use one Implementation instance per database
        // it's recommended to share the Implementation and Database instances
        // in the application, instead of always instantiate and open it.
        Implementation odmg = OJB.getInstance();
        Database       db   = odmg.newDatabase();

        // open database
        try
        {
            db.open(DATABASE_NAME, Database.OPEN_READ_WRITE);
View Full Code Here

     * Note: The name attribute was declared as
     * unique in the DB.
     */
    public void testDuplicateInsertion() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        String name = "testDuplicateInsertion_" + System.currentTimeMillis();
        String nameNew = "testDuplicateInsertion_New_" + System.currentTimeMillis();

        db.open(databaseName, Database.OPEN_READ_WRITE);
        //System.out.println("TEST: Database open");
View Full Code Here

        tx.commit();
    }

    public void testSimpleQueryDelete() throws Exception
    {
        Implementation odmg = OJB.getInstance();
        Database db = odmg.newDatabase();
        String name = "testSimpleQueryDelete - " + System.currentTimeMillis();

        db.open(databaseName, Database.OPEN_READ_WRITE);
        Site site = new Site();
        site.setName(name);
        Transaction tx = odmg.newTransaction();
        tx.begin();
        tx.lock(site, Transaction.WRITE);
        tx.commit();

        OQLQuery query = odmg.newOQLQuery();
        query.create("select sites from " + Site.class.getName() + " where name=$1");
        query.bind(name);
        tx.begin();
        List result = (List) query.execute();
        if (result.size() == 0)
        {
            fail("Stored object not found");
        }
        tx.commit();

        tx.begin();
        db.deletePersistent(site);
        tx.commit();

        query = odmg.newOQLQuery();
        query.create("select sites from " + Site.class.getName() + " where name=$1");
        query.bind(name);
        tx.begin();
        List result2 = (List) query.execute();
        if (result2.size() > 0)
View Full Code Here

TOP

Related Classes of org.odmg.Implementation

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.