Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreService.beginTransaction()


   
   
   
    txn.commit();
   
    Transaction txn2 = datastore.beginTransaction();datastore.put(function2);
    txn2.commit();
   
  }

}
View Full Code Here


    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");
        b2.setProperty("Id",KeyFactory.keyToString(kb));
View Full Code Here

     * @return true if in-container, false otherewise
     */
    protected static boolean isInContainer() {
        try {
            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            Transaction tx = ds.beginTransaction();
            try {
                return (ds.getCurrentTransaction() != null);
            } finally {
                tx.rollback();
            }
View Full Code Here

        }
    }

    public static Key putTempData(TempData data) {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        Transaction txn = ds.beginTransaction(TransactionOptions.Builder.withXG(true));
        try {
            Class<? extends TempData> type = data.getClass();
            String kind = getKind(type);
            Entity entity = new Entity(kind);
            for (Map.Entry<String, Object> entry : data.toProperties(ds).entrySet()) {
View Full Code Here

    public void testAutoPolicy() throws Exception {
        DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withImplicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.AUTO);
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService(config);

        Key k1 = null;
        Transaction tx = ds.beginTransaction();
        try {
            // this one should be part of auto Tx
            k1 = ds.put(new Entity("PutAutoTx"));
        } finally {
            tx.rollback();
View Full Code Here

        k1 = ds.put(new Entity("DeleteAutoTx"));
        try {
            Assert.assertNotNull(ds.get(k1));

            tx = ds.beginTransaction();
            try {
                // this one should be part of auto Tx
                ds.delete(k1);
            } finally {
                tx.rollback();
View Full Code Here

        Entity entity = new Entity(entityGroup, parentKey);
        entity.setProperty("foo", RANDOM.nextInt());

        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        final Transaction tx = ds.beginTransaction(TransactionOptions.Builder.withXG(xg));
        try {
            log.warning("Before put ... " + counter);
            putEntity(ds, entity);
            log.warning("After put ... " + counter);
            tx.commit();
View Full Code Here

        }
    }

    private void saveEntity(Entity entity) {
        DatastoreService service = DatastoreServiceFactory.getDatastoreService();
        Transaction tx = service.beginTransaction();
        try {
            service.put(tx, entity);
            tx.commit();
        } finally {
            if (tx.isActive()) {
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.