Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Transaction.rollback()


        tx = service.beginTransaction();
        qRec = service.get(key);
        qRec.setUnindexedProperty("step", "update");
        service.put(tx, newRec);
        tx.rollback();
        qRec = service.get(key);
        assertEquals("added", qRec.getProperty("step"));
    }

    // multiple entities in same group with default transaction setting
View Full Code Here


        TransactionOptions tos = TransactionOptions.Builder.withXG(true);
        Transaction tx = service.beginTransaction(tos);
        es.get(0).setProperty("check", "parent-update");
        es.get(1).setProperty("check", "other-update");
        service.put(tx, es);
        tx.rollback();
        es = readMultipleGroup(keys);
        assertEquals("parent", es.get(0).getProperty("check"));
        assertEquals("other", es.get(1).getProperty("check"));
    }
View Full Code Here

                ens2.setProperty("stamp", new Date());
                es.add(ens2);
                service.put(tx, es);
                tx.commit();
            } catch (Exception e) {
                tx.rollback();
                throw e;
            }
        } finally {
            NamespaceManager.set("");
        }
View Full Code Here

            keys.secondParent = service.put(tx, other);
            tx.commit();

            sync(sleepTime);
        } catch (Exception e) {
            tx.rollback();
            throw e;
        }
        sync(sleepTime);

        return keys;
View Full Code Here

            log.warning("After put ... " + counter);
            tx.commit();
            resp.getWriter().write("OK" + counter);
        } catch (Exception e) {
            log.warning("Error ... " + e);
            tx.rollback();
            resp.getWriter().write("ERROR" + counter + ":" + e.getClass().getName());
            error(counter);
        } finally {
            cleanup(counter);
        }
View Full Code Here

            service.put(tx, es);
            tx.commit();

            sync(sleepTime);
        } catch (Exception e) {
            tx.rollback();
            throw e;
        }
        sync(sleepTime);
        return keys;
    }
View Full Code Here

        clearData();
        Entity newRec = new Entity(ASYNC_ENTITY);
        newRec.setProperty("timestamp", new Date());
        Transaction trans = asyncService.beginTransaction().get();
        Future<Key> firstE = asyncService.put(trans, newRec);
        trans.rollback();
        assertEquals(0, service.prepare(new Query(ASYNC_ENTITY)).countEntities(withDefaults()));

        // Add a parent
        newRec = new Entity(ASYNC_ENTITY);
        newRec.setProperty("count", 0);
View Full Code Here

        Transaction tx = DatastoreServiceFactory.getDatastoreService().beginTransaction();
        try {
            TaskOptions options = TaskOptions.Builder.withTaskName("foo");
            getDefaultQueue().add(tx, new TaskOptions(options));
        } finally {
            tx.rollback();
        }
    }

    @Test(expected = IllegalArgumentException.class)
    public void testTransactionalTasksMustBeNamelessIterable() {
View Full Code Here

    public void testTransactionalTasksMustBeNamelessIterable() {
        Transaction tx = DatastoreServiceFactory.getDatastoreService().beginTransaction();
        try {
            getDefaultQueue().add(tx, Collections.singleton(TaskOptions.Builder.withTaskName("foo")));
        } finally {
            tx.rollback();
        }
    }

    @Test(expected = TaskAlreadyExistsException.class)
    public void testAddingTwoTasksWithSameNameThrowsException() {
View Full Code Here

        try {
            key = waitOnFuture(service.put(tx, new Entity("AsyncTx")));
            key2 = waitOnFuture(service.put(tx, new Entity("AsyncTx")));
            tx.commit();
        } catch (Exception e) {
            tx.rollback();
            throw e;
        }

        if (key != null && key2 != null) {
            tx = waitOnFuture(service.beginTransaction(TransactionOptions.Builder.withXG(true)));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.