Package com.google.appengine.datanucleus

Examples of com.google.appengine.datanucleus.ExceptionThrowingDatastoreDelegate


            }
          }
        };

    ApiProxy.Delegate original = getDelegateForThread();
    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);

    try {
      javax.persistence.Query q = em.createQuery(
          "select from " + Book.class.getName() + " c");
View Full Code Here


              throw new ConcurrentModificationException();
            }
            count++;
          }
        };
    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);
    try {
      Flight flight = new Flight();
      flight.setName("harold");
      flight.setOrigin("bos");
      flight.setDest("mia");
      flight.setYou(23);
      flight.setMe(24);
      flight.setFlightNumber(88);
      beginTxn();
      pm.makePersistent(flight);
      try {
        commitTxn();
        fail("expected exception");
      } catch (JDODataStoreException e) {
        // good
        assertTrue(e.getCause() instanceof ConcurrentModificationException);
      }
      assertFalse(pm.currentTransaction().isActive());
      assertEquals(flight, "harold", "bos", "mia", 23, 24, 88);
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    ds.put(e);
    beginTxn();
    Flight f = pm.detachCopy(pm.getObjectById(Flight.class, e.getKey()));
    commitTxn();

    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);

    try {
      // update detached object
      f.setYou(12);
      beginTxn();

      // reattach
      pm.makePersistent(f);
      try {
        commitTxn();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      assertFalse(pm.currentTransaction().isActive());
      beginTxn();
      pm.makePersistent(f);
      commitTxn();
      beginTxn();
      f = pm.getObjectById(Flight.class, e.getKey());
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
      commitTxn();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    beginTxn();
    Flight f = pm.getObjectById(Flight.class, e.getKey());
    // make a copy right away, otherwise our change will get reverted
    // when the txn rolls back
    Flight fCopy = pm.detachCopy(f);
    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);

    try {
      // update attached object
      fCopy.setYou(12);
      pm.makePersistent(fCopy);
      try {
        commitTxn();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      assertFalse(pm.currentTransaction().isActive());
      beginTxn();
      pm.makePersistent(fCopy);
      commitTxn();
      beginTxn();
      f = pm.getObjectById(Flight.class, e.getKey());
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
      commitTxn();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    Entity e = Flight.newFlightEntity("harold", "bos", "mia", 23, 24, 88);
    ds.put(e);
    Flight f = pm.detachCopy(pm.getObjectById(Flight.class, e.getKey()));
    pm.close();
    pm = pmf.getPersistenceManager();
    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);

    try {
      // update detached object
      f.setYou(12);

      // reattach
      try {
        pm.makePersistent(f);
        pm.close();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      pm = pmf.getPersistenceManager();
      pm.makePersistent(f);
      pm.close();
      pm = pmf.getPersistenceManager();
      f = pm.getObjectById(Flight.class, e.getKey());
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
      pm.close();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

    ds.put(e);
    Flight f = pm.getObjectById(Flight.class, e.getKey());
    // make a copy right away, otherwise our change will get reverted
    // when the txn rolls back
    Flight fCopy = pm.detachCopy(f);
    ExceptionThrowingDatastoreDelegate dd =
        new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
    setDelegateForThread(dd);

    try {
      // update attached object
      fCopy.setYou(12);
      try {
        pm.makePersistent(fCopy);
        pm.close();
        fail("expected exception");
      } catch (JDODataStoreException ex) {
        // good
        assertTrue(ex.getCause() instanceof ConcurrentModificationException);
      }
      pm = pmf.getPersistenceManager();
      pm.makePersistent(fCopy);
      pm.close();
      pm = pmf.getPersistenceManager();
      f = pm.getObjectById(Flight.class, e.getKey());
      assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
      pm.close();
    } finally {
      setDelegateForThread(dd.getInner());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.ExceptionThrowingDatastoreDelegate

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.