Package org.apache.ojb.otm.core

Examples of org.apache.ojb.otm.core.Transaction


     * bound to.
     */
    public Transaction getTransaction(OTMConnection conn)
    {
        TransactionFactory txFactory = getTransactionFactory();
        Transaction tx = txFactory.getTransactionForConnection(conn);
        tx.setKit(this);
        return tx;
    }
View Full Code Here


      else
        msg.append(" null. Make sure you pass a non-null OTMConnection to this method. An OTMConnection can be acquired by calling acquireConnection (PBKey pbKey)");
            throw new TransactionFactoryException(msg.toString());
        }

        Transaction tx = (Transaction) _transactionMap.get(connection);
        if (tx == null)
        {
            tx = new Transaction();
            _transactionMap.put(connection, tx);
        }
        // ensure that this connection is registered into this transaction
        tx.registerConnection(connection);
        return tx;
    }
View Full Code Here

        if (jtaTx == null)
        {
            throw new TransactionFactoryException("Unable to get the JTA Transaction");
        }

        Transaction tx = (Transaction) _transactionMap.get(jtaTx);
        if (tx == null)
        {
            tx = new Transaction();
            _transactionMap.put(jtaTx, tx);
        }

        // ensure that this connection is registered into this transaction
        tx.registerConnection(baseConnection);
        return tx;
  }
View Full Code Here

     * @see org.apache.ojb.otm.lock.TransactionIsolation#readLock(Transaction, ObjectLocks)
     */
    public void readLock(Transaction tx, ObjectLock lock)
        throws LockingException
    {
        Transaction writer = lock.getWriter();
        if (writer == null)
        {
            lock.readLock(tx);
            if (lock.getWriter() != null)
            {
View Full Code Here

                readLock(tx, lock);
            }
        }
        else
        {
            Transaction reader = (Transaction) readers.iterator().next();

            if (reader != tx) {
                lock.waitForTx(reader);
            }
        }
View Full Code Here

            readLock(tx, lock);
            writeLock(tx, lock);
        }
        else
        {
            Transaction reader = (Transaction) readers.iterator().next();
            if (reader == tx)
            {
                lock.writeLock(tx);
            }
            else
View Full Code Here

    * @see org.apache.ojb.otm.lock.wait.LockWaitStrategy#waitForLock(ObjectLock, Transaction)
    */
    public void waitForLock(ObjectLock lock, Transaction tx)
        throws LockingException
    {
        Transaction writerTx;
        ObjectLock writerWaitsForLock;

        // test for deadlock
        writerTx = lock.getWriter();
        while (writerTx != null)
View Full Code Here

     */
    public static void storeProduct(Product product) throws LockingException
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            conn.makePersistent(product);

            tx.commit();
        }
        catch (LockingException ex)
        {
            if (tx.isInProgress())
            {
                tx.rollback();
            }
            throw ex;
        }
        finally
        {
View Full Code Here

     */
    public static void removeProduct(Product product) throws LockingException
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;

        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            conn.deletePersistent(product);

            tx.commit();
        }
        catch (LockingException ex)
        {
            if (tx.isInProgress())
            {
                tx.rollback();
            }
            throw ex;
        }
        finally
        {
View Full Code Here

     */
    public Iterator findByCriteria(Query query)
    {
        OTMKit        kit  = SimpleKit.getInstance();
        OTMConnection conn = null;
        Transaction   tx   = null;
        try
        {
            conn = kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
            tx   = kit.getTransaction(conn);

            tx.begin();

            Iterator results = conn.getIteratorByQuery(query);

            tx.commit();

            return results;
        }
        finally
        {
View Full Code Here

TOP

Related Classes of org.apache.ojb.otm.core.Transaction

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.