Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.TransactionOptions


  }

  // visible for testing
  static TransactionOptions copyTransactionOptions(TransactionOptions txnOpts) {
    // Maintenance nightmare, use clone() once it's available in the sdk
    TransactionOptions options = TransactionOptions.Builder.withDefaults();
    if (txnOpts.isXG()) {
      options.setXG(txnOpts.isXG());
    } else {
      options.clearXG();
    }
    return txnOpts;
  }
View Full Code Here


     *     // do something in that transaction
     * }
     * </code>
     */
    public static Transaction withTransaction(DatastoreService service, boolean crossGroup, Closure<?> c) {
        TransactionOptions opts = crossGroup ? TransactionOptions.Builder.withXG(true) : TransactionOptions.Builder.withDefaults();
        Transaction transaction = service.beginTransaction(opts);
        try {
            // pass the transaction as single parameter of the closure
            c.call(transaction);
            // commit the transaction if the Closure<?> executed without throwing an exception
View Full Code Here

     * </code>
     * @throws ExecutionException
     * @throws InterruptedException
     */
    public static Future<Transaction> withTransaction(AsyncDatastoreService service, boolean crossGroup, Closure<?> c) throws InterruptedException, ExecutionException {
        TransactionOptions opts = crossGroup ? TransactionOptions.Builder.withXG(true) : TransactionOptions.Builder.withDefaults();
        Future<Transaction> transaction = service.beginTransaction(opts);
        try {
            // pass the transaction as single parameter of the closure
            c.call(transaction);
            // commit the transaction if the Closure<?> executed without throwing an exception
View Full Code Here

    EntityManager em = EMF.lookupEntityManager();
    EntityTransaction tx = em.getTransaction();
   
   
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();   
    TransactionOptions options = TransactionOptions.Builder.withXG(true);   
    Transaction txn = datastore.beginTransaction(options);
   
    try {     
     
      if (condicio != "")
View Full Code Here

            }
        }
                     
       
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();   
        TransactionOptions options = TransactionOptions.Builder.withXG(true);   
        Transaction txn = datastore.beginTransaction(options);
               
        // Creem Book
        Entity b2 = new Entity("Book2");
        Key kb= KeyFactory.createKey("Book2", "Title");
View Full Code Here

    }

    // transactionOptions setting
    @Test
    public void testTransactionOptions() {
        TransactionOptions tos = TransactionOptions.Builder.withXG(true);
        assertEquals(true, tos.isXG());
        tos.clearXG();
        assertEquals(false, tos.isXG());
    }
View Full Code Here

        clearData(kindName);
        clearData(otherKind);
        GroupParentKeys keys = writeMultipleGroup(true);
        List<Entity> es = readMultipleGroup(keys);

        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();
View Full Code Here

        NamespaceManager.set("");
        clearData(kindName);
        NamespaceManager.set("trns");
        try {
            clearData(kindName);
            TransactionOptions tos = TransactionOptions.Builder.withXG(false);
            Transaction tx = service.beginTransaction(tos);
            try {
                List<Entity> es = new ArrayList<>();
                NamespaceManager.set("");
                Entity ens1 = new Entity(kindName);
View Full Code Here

        NamespaceManager.set("");
        clearData(kindName);
        NamespaceManager.set("trns");
        clearData(kindName);
        List<Entity> es = new ArrayList<>();
        TransactionOptions tos = TransactionOptions.Builder.withXG(true);
        Transaction tx = service.beginTransaction(tos);

        NamespaceManager.set("");
        Entity ens1 = new Entity(kindName);
        ens1.setProperty("check", "entity-nons");
View Full Code Here

    private GroupParentKeys writeMultipleGroup(boolean allow) throws Exception {

        GroupParentKeys keys = new GroupParentKeys();

        TransactionOptions tos = TransactionOptions.Builder.withXG(allow);
        Transaction tx = service.beginTransaction(tos);
        try {
            Entity parent = new Entity(kindName);
            parent.setProperty("check", "parent");
            parent.setProperty("stamp", new Date());
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.TransactionOptions

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.