Package javax.jdo

Examples of javax.jdo.Transaction


    /** */
    private boolean doPersistentInstancesExist()
    {
        boolean ret;
        Transaction t = pm.currentTransaction();
        t.begin();
        Extent e = pm.getExtent(StateTransitionObj.class, false);
        Iterator iter = e.iterator();
        ret = iter.hasNext();
        t.rollback();
        return ret;
    }
View Full Code Here


    else
    {
          pm = getPM();
      PCPoint2 pt = getHollowInstance();

      Transaction tx = pm.currentTransaction();
      tx.setRetainValues(false); //This should cause eviction of transactional instances when transaction is later commited.
           
      //Test
      tx.begin();
      makePersistentClean(pt);
      tx.commit(); // This should evict pt
      verify(pt);
    }
    }
View Full Code Here

    }
    }

  /** */
    private PCPoint2 getHollowInstance() {
        Transaction tx = pm.currentTransaction();
        tx.begin();
        PCPoint2 pt = new PCPoint2(1,2);
        pm.makePersistent(pt);
        tx.commit();

    int curr = currentState(pt);
      if (curr != HOLLOW){
      fail(ASSERTION_FAILED,
           "Unable to create HOLLOW instance, state is " + states[curr]);
View Full Code Here

        p5 = new PCPoint(5,7);
    }

    /* test makePersistent (Object pc) */
    private void runTestMakePersistent1(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            pm.makePersistent(p1);
            tx.commit();
            tx = null;
            if (debug) logger.debug(" \nPASSED in runTestMakePersistent1()");
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

        }
    }

    /* test makePersistentAll (Collection pcs) */
    private void runTestMakePersistent2(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Collection col1 = new HashSet();
            col1.add(p2);
            col1.add(p3);
           
            pm.makePersistentAll(col1);
            tx.commit();
            tx = null;
            if (debug) logger.debug(" \nPASSED in runTestMakePersistent2()");
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

        }
    }
   
    /* test makePersistentAll (Object[] o) */
    private void runTestMakePersistent3(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        try {
            tx = pm.currentTransaction();
            tx.begin();
           
            Collection col1 = new HashSet();
            col1.add(p1);
            col1.add(p2);
           
            Object[] obj1= col1.toArray();
           
            pm.makePersistentAll(obj1);
            tx.commit();
            tx = null;
            if (debug) logger.debug (" \nPASSED in runTestMakePersistent3()");
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

        }
    }
   
    /* test makePersistent (Object pc) */
    private void runTestMakePersistent4(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        if (tx.isActive())
            tx.rollback();

        PCPoint np1 = new PCPoint(1,3);
        try {
            pm.makePersistent(np1);
            fail(ASSERTION_FAILED,
View Full Code Here

        }
    }

    /* test makePersistentAll (Collection pcs) */
    private void runTestMakePersistent5(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        if (tx.isActive())
            tx.rollback();

        PCPoint np1 = new PCPoint (3,3);
        PCPoint np2 = new PCPoint (4,4);
       
        Collection col1 = new HashSet();
View Full Code Here

        insertPCPoints(pm, 5);
    }

    /** */
    protected void insertPCPoints(PersistenceManager pm, int numInsert) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            for(int i = 0; i<numInsert; i++) {
                Object pc = new PCPoint(i, i);
                pm.makePersistent(pc);
                inserted.add(pc);
            }
            tx.commit();
            tx = null;
            if (debug) logger.debug("Total objects inserted : " + numInsert);
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

        }
    }

    /* test makePersistentAll (Object[] o) */
    private void runTestMakePersistent6(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        if (tx.isActive())
            tx.rollback();

        PCPoint np1 = new PCPoint (3,3);
        PCPoint np2 = new PCPoint (4,4);
       
        Collection col1 = new HashSet();
View Full Code Here

TOP

Related Classes of javax.jdo.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.