Package org.apache.ojb.odmg

Examples of org.apache.ojb.odmg.TransactionExt


    public PBKey getPBKey()
    {
        if(pbKey == null)
        {
            TransactionExt tx = getTransaction();
            if(tx != null && tx.isOpen())
            {
                pbKey = tx.getBroker().getPBKey();
            }
        }
        return pbKey;
    }
View Full Code Here


        {
            return keyRealSubject;
        }
        else
        {
            TransactionExt tx = getTransaction();

            if((tx != null) && tx.isOpen())
            {
                prepareKeyRealSubject(tx.getBroker());
            }
            else
            {
                if(getPBKey() != null)
                {
View Full Code Here

        {
            return valueRealSubject;
        }
        else
        {
            TransactionExt tx = getTransaction();

            if((tx != null) && tx.isOpen())
            {
                prepareValueRealSubject(tx.getBroker());
            }
            else
            {
                if(getPBKey() != null)
                {
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

        /*
        store list of objects, then get these objects with Iterator, start
        iteration, then break
        */
        storeObjects(objects);
        TransactionExt tx = ((TransactionExt) odmg.currentTransaction());
        // force writing to DB
        tx.flush();
        Class searchClass = objects.get(0).getClass();
        PersistenceBroker broker = tx.getBroker();
        Query q = new QueryByCriteria(searchClass, new Criteria());
        // we get the iterator and step into the first found object
        Iterator it = broker.getIteratorByQuery(q);
        it.next();
        // now the iterator resources may not release, see what's going on
View Full Code Here

    {
        /* One possibility of storing objects is to use the current transaction
         associated with the container */
        try
        {
            TransactionExt tx = (TransactionExt) odmg.currentTransaction();
            tx.lock(object, Transaction.WRITE);
            tx.markDirty(object);
        }
        catch (LockNotGrantedException e)
        {
            log.error("Failure while storing object " + object, e);
            throw new OJBRuntimeException("Failure while storing object", e);
View Full Code Here

        /*
        store list of objects, then get these objects with Iterator, start
        iteration, then break
        */
        storeObjects(objectsToStore);
        TransactionExt tx = ((TransactionExt) getImplementation().currentTransaction());
        // force writing to DB
        tx.flush();
        Class searchClass = objectsToStore.get(0).getClass();
        PersistenceBroker broker = tx.getBroker();
        Query q = new QueryByCriteria(searchClass);
        // we get the iterator and step into the first found object
        Iterator it = broker.getIteratorByQuery(q);
        it.next();
        /*
 
View Full Code Here

    {
        /* One possibility of storing objects is to use the current transaction
         associated with the container */
        try
        {
            TransactionExt tx = (TransactionExt) odmg.currentTransaction();
            tx.lock(object, Transaction.WRITE);
            tx.markDirty(object);
        }
        catch (LockNotGrantedException e)
        {
            log.error("Failure while storing object " + object, e);
            throw new EJBException("Failure while storing object", e);
View Full Code Here

     * been inserted by <code>insertNewArticles()</code>.
     * The lookup is done one by one, that is: a primary key based lookup is used.
     */
    protected void readArticles() throws Exception
    {
        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        // we don't want implicite locks when compare performance
        tx.setImplicitLocking(false);
        String sql = "select allArticles from " + PerformanceArticle.class.getName() + " where articleId=$1";
        long start = System.currentTimeMillis();
        tx.begin();
        for(int i = 0; i < articleCount; i++)
        {
            OQLQuery query = odmg.newOQLQuery();
            query.create(sql);
            query.bind(arr[i].getArticleId());
            query.execute();
        }
        tx.commit();
        long stop = System.currentTimeMillis();
        logger.info("querying " + articleCount + " Objects: " + (stop - start) + " msec");
    }
View Full Code Here

     * that is: a between Statement is used to select all inserted PerformanceArticles
     * and Objects are read in by fetching from the cursor (JDBC ResultSet).
     */
    protected void readArticlesByCursor() throws Exception
    {
        TransactionExt tx = (TransactionExt) odmg.newTransaction();
        // we don't want implicite locks when compare performance
        tx.setImplicitLocking(false);
        tx.begin();
        // clear cache to read from DB
        tx.getBroker().clearCache();

        long start = System.currentTimeMillis();
        OQLQuery query = odmg.newOQLQuery();
        String sql = "select allArticles from " + PerformanceArticle.class.getName()
                + " where articleId between " + new Integer(offsetId) + " and "
View Full Code Here

TOP

Related Classes of org.apache.ojb.odmg.TransactionExt

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.