Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.LockedByVersion


    {
        long timestamp = System.currentTimeMillis();
        String name = "testMultipleLocks_" + timestamp;
        String nameUpdated = "testMultipleLocks_Updated_" + timestamp;
        TransactionExt tx = (TransactionExt) odmg1.newTransaction();
        LockedByVersion obj = new LockedByVersion();
        tx.begin();
        tx.lock(obj, Transaction.WRITE);
        obj.setValue(name);
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.UPGRADE);
        tx.commit();

        OQLQuery query = odmg1.newOQLQuery();
        query.create("select all from " + LockedByVersion.class.getName() + " where value like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        assertNotNull(result);
        assertEquals(1, result.size());

        tx.begin();
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.WRITE);
        obj.setValue(nameUpdated);
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.UPGRADE);
        tx.commit();

        query = odmg1.newOQLQuery();
View Full Code Here


    public void testOptimisticLockBasics() throws Exception
    {
        TransactionImpl tx1 = (TransactionImpl) odmg1.newTransaction();
        TransactionImpl tx2 = (TransactionImpl) odmg2.newTransaction();

        LockedByVersion obj = new LockedByVersion();


        tx1.begin();

        tx1.lock(obj,Transaction.WRITE);
    obj.setValue("tx1");
    tx1.commit();

    obj.setVersion(obj.getVersion() - 1);
    tx2.begin();
    tx2.lock(obj,Transaction.WRITE);

    obj.setValue("tx2");
    boolean signalOLException = false;
    try
    {
      tx2.commit();
    }
View Full Code Here

    {
        long timestamp = System.currentTimeMillis();
        String name = "testMultipleLocks_" + timestamp;
        String nameUpdated = "testMultipleLocks_Updated_" + timestamp;
        TransactionExt tx = (TransactionExt) odmg1.newTransaction();
        LockedByVersion obj = new LockedByVersion();
        tx.begin();
        tx.lock(obj, Transaction.WRITE);
        obj.setValue(name);
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.UPGRADE);
        tx.commit();

        OQLQuery query = odmg1.newOQLQuery();
        query.create("select all from " + LockedByVersion.class.getName() + " where value like $1");
        query.bind(name);
        Collection result = (Collection) query.execute();
        assertNotNull(result);
        assertEquals(1, result.size());

        tx.begin();
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.WRITE);
        obj.setValue(nameUpdated);
        tx.lock(obj, Transaction.WRITE);
        tx.lock(obj, Transaction.UPGRADE);
        tx.commit();

        query = odmg1.newOQLQuery();
View Full Code Here

    public void testOptimisticLockBasics() throws Exception
    {
        TransactionImpl tx1 = (TransactionImpl) odmg1.newTransaction();
        TransactionImpl tx2 = (TransactionImpl) odmg2.newTransaction();

        LockedByVersion obj = new LockedByVersion();


        tx1.begin();

        tx1.lock(obj,Transaction.WRITE);
    obj.setValue("tx1");
    tx1.commit();

    obj.setVersion(obj.getVersion() - 1);
    tx2.begin();
    tx2.lock(obj,Transaction.WRITE);

    obj.setValue("tx2");
    try
    {
      tx2.commit();
            // OL exceptions should be signalled as ODMG LockNotGrantedExceptions
            // so that users can react accordingly
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.LockedByVersion

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.