Package org.odmg

Examples of org.odmg.Transaction.begin()


    public void testDBag() throws Exception
    {
        String name = "testDBag_" + System.currentTimeMillis();

        Transaction tx = odmg.newTransaction();
        tx.begin();
        DBag bag1 = odmg.newDBag();
        DBag bag2 = odmg.newDBag();
        DObject a, b, c, d, e;
        a = createObject(name);
        b = createObject(name);
View Full Code Here


        // now perform persistence operations

        // 3. open transaction
        Transaction tx = odmg.newTransaction();

        tx.begin();

        // 4. acquire write lock on new object
        tx.lock(newProduct, Transaction.WRITE);

        // 5. commit transaction
View Full Code Here

    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

    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);
View Full Code Here

    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);

        tx.commit();
View Full Code Here

    public static void deleteProduct(Product product)
    {
        Implementation impl = OJB.getInstance();
        Transaction    tx = impl.newTransaction();

        tx.begin();

        Database db = impl.getDatabase(product);

        db.deletePersistent(product);
View Full Code Here

        try
        {
            // 1. open a transaction
            Transaction tx = odmg.newTransaction();

            tx.begin();

            // 2. get an OQLQuery object from the ODMG facade
            OQLQuery query = odmg.newOQLQuery();

            // 3. set the OQL select statement
View Full Code Here

        clearNRM();

        Article example = createArticle();

        Transaction tx = odmg.newTransaction();
        tx.begin();
        try
        {
            db.bind(example, bindingName);
            Article value = (Article) db.lookup(bindingName);
            assertTrue("Could not lookup object for binding name: "+bindingName, value != null);
View Full Code Here

            fail("should not have happened: " + e.getMessage());
        }

        try
        {
            tx.begin();
            db.bind(example, bindingName);
            tx.commit();
            fail("We expected a ObjectNameNotUniqueException, but was not thrown");
        }
        catch (ObjectNameNotUniqueException ex)
View Full Code Here

            tx.abort();
        }

        try
        {
            tx.begin();
            db.unbind(bindingName);
            tx.commit();
        }
        catch (ObjectNameNotFoundException ex)
        {
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.