Package org.odmg

Examples of org.odmg.Transaction.lock()


        Transaction tx = odmg.newTransaction();
        tx.begin();
        // add objects to list
        for (int i = 0; i < 5; i++)
        {
            tx.lock(createObject(name), Transaction.WRITE);
        }
        tx.commit();

        tx.begin();
        // query test objects
View Full Code Here


        // check result list size
        assertEquals(5, ret.size());
        // do read lock
        for (Iterator it = ret.iterator(); it.hasNext(); )
        {
            tx.lock(it.next(), Transaction.READ);
        }
        // create new list for results
        ArrayList result = new ArrayList();
        result.addAll(ret);
        tx.commit();
View Full Code Here

            List   result     = (List)query.execute();
            Product toBeEdited = (Product)result.get(0);

            // 4. lock the product for write access
            tx.lock(toBeEdited, Transaction.WRITE);

            // 5. Edit the product entry
            System.out.println("please edit existing product");
            in = readLineWithMessage("enter name (was " + toBeEdited.getName() + "):");
            toBeEdited.setName(in);
View Full Code Here

            // check whether object's class is persistence capable
            PersistenceBroker broker = ((HasBroker) tx).getBroker();
            broker.getClassDescriptor(object.getClass());
            // if a ClassDescriptor was found, OJB knows how to persist the object
            // lock object for write in tx
            tx.lock(object, Transaction.WRITE);
        }
        catch (
                org
                .apache
                .ojb
View Full Code Here

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

        Transaction tx = odmg.newTransaction();
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        tx.lock(obj_3, Transaction.WRITE);
        tx.commit();

        Criteria crit = new Criteria();
View Full Code Here

        db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);

        Transaction tx = odmg.newTransaction();
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        tx.lock(obj_3, Transaction.WRITE);
        tx.commit();

        Criteria crit = new Criteria();
        crit.addEqualTo("name", name);
View Full Code Here

        Transaction tx = odmg.newTransaction();
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        tx.lock(obj_3, Transaction.WRITE);
        tx.commit();

        Criteria crit = new Criteria();
        crit.addEqualTo("name", name);
        QueryByCriteria query = QueryFactory.newQuery(MainObject.class, crit);
View Full Code Here

        // add new reference to object
        CollectionReference ref_5 = new CollectionReference(null, nameRef);
        CollectionReference ref_6 = new CollectionReference(null, nameRef);
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        obj_1.addReference(ref_5);
        obj_2.addReference(ref_6);
        tx.commit();
        assertNotNull(ref_5.getRefIdentifier());
View Full Code Here

        // add new reference to object
        CollectionReference ref_5 = new CollectionReference(null, nameRef);
        CollectionReference ref_6 = new CollectionReference(null, nameRef);
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        obj_1.addReference(ref_5);
        obj_2.addReference(ref_6);
        tx.commit();
        assertNotNull(ref_5.getRefIdentifier());
        assertNotNull(ref_6.getRefIdentifier());
View Full Code Here

        assertEquals(id_1, obj_1.getIdentifier());
        assertEquals(id_2, obj_2.getIdentifier());

        // now update main objects
        tx.begin();
        tx.lock(obj_1, Transaction.WRITE);
        tx.lock(obj_2, Transaction.WRITE);
        obj_1.setName(name+"_update");
        obj_2.setName(name+"_update");
        tx.commit();
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.