Package com.google.appengine.api.datastore

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


          ds.put(putMe.get(0));
        } else {
          ds.put(putMe);
        }
      } else {
        Transaction innerTxn = txn.getInnerTxn();
        if (putMe.size() == 1) {
          ds.put(innerTxn, putMe.get(0));
        } else {
          ds.put(innerTxn, putMe);
        }
View Full Code Here


        ds.delete(keys.get(0));
      } else {
        ds.delete(keys);
      }
    } else {
      Transaction innerTxn = txn.getInnerTxn();
      if (keys.size() == 1) {
        ds.delete(innerTxn, keys.get(0));
      } else {
        ds.delete(innerTxn, keys);
      }
View Full Code Here

      return wrapEntityQueryResult(entityIterable, qd.resultTransformer, ds, null);
    } else {
      // Normal query
      latestDatastoreQuery = qd.primaryDatastoreQuery;
      Transaction txn = null;
      // give users a chance to opt-out of having their query execute in a txn
      if (extensions == null ||
          !extensions.containsKey(DatastoreManager.QUERYEXT_EXCLUDE_FROM_TXN) ||
          !(Boolean)extensions.get(DatastoreManager.QUERYEXT_EXCLUDE_FROM_TXN)) {
        // If this is an ancestor query, execute it in the current transaction
View Full Code Here

    }
  }

  private Object executeBatchGetQuery(DatastoreService ds, QueryData qd) {
    DatastoreTransaction txn = getStoreManager().getDatastoreTransaction(getExecutionContext());
    Transaction innerTxn = txn == null ? null : txn.getInnerTxn();
    if (isBulkDelete()) {
      Set<Key> keysToDelete = qd.batchGetKeys;
      Map extensions = query.getExtensions();
      if (extensions != null &&
          extensions.containsKey(DatastoreManager.QUERYEXT_SLOW_BUT_MORE_ACCURATE_JPQL_DELETE) &&
View Full Code Here

    private static final Key _SERVICE_STATUS_KEY =
        KeyFactory.createKey("ServiceStatus", "1");

    public static Entity getStatusEntity() {
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Transaction txn = datastore.beginTransaction();
        Entity status;
        try {
            status = datastore.get(txn, _SERVICE_STATUS_KEY);
        } catch (EntityNotFoundException e) {
            status = new Entity(_SERVICE_STATUS_KEY);
            status.setProperty("presence_available", true);
            status.setProperty("presence_show",
                               presenceShowStrings[PresenceShow.CHAT.ordinal()]);
            datastore.put(txn, status);
        }
        txn.commit();
        return status;
    }
View Full Code Here

    // Get or create a user entity for a JID.  This truncates the
    // resource portion of the JID, so multiple user clients are
    // consolidated into one record per account.
    public static Entity getUserEntity(JID jid) {
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Transaction txn = datastore.beginTransaction();
        String jidStr = jid.getId();
        if (jidStr.indexOf("/") != -1) {
            jidStr = jidStr.substring(0, jidStr.indexOf("/"));
        }
        Key userKey = KeyFactory.createKey("ChatUser", jidStr);
        Entity userEntity;
        try {
            userEntity = datastore.get(txn, userKey);
        } catch (EntityNotFoundException e) {
            userEntity = new Entity(userKey);
            userEntity.setProperty("jid", jidStr);
            userEntity.setProperty("accepted_invitation", false);
            userEntity.setProperty("is_subscribed", false);
            userEntity.setProperty("is_available", false);
            userEntity.setProperty("presence_show", "chat");
            userEntity.setProperty("status_message", "");
            userEntity.setProperty("last_chat_message", "");
            datastore.put(txn, userEntity);
        }
        txn.commit();
        return userEntity;
    }
View Full Code Here

        int retries = 3;
        boolean success = false;
        while (!success && retries > 0) {
            --retries;
            try {
                Transaction txn = ds.beginTransaction();

                Key boardKey;
                Entity messageBoard;
                try {
                    boardKey = KeyFactory.createKey("MessageBoard", boardName);
                    messageBoard = ds.get(boardKey);

                } catch (EntityNotFoundException e) {
                    messageBoard = new Entity("MessageBoard", boardName);
                    messageBoard.setProperty("count", 0L);
                    boardKey = ds.put(messageBoard);
                }

                Entity message = new Entity("Message", boardKey);
                message.setProperty("message_title", messageTitle);
                message.setProperty("message_text", messageText);
                message.setProperty("post_date", postDate);
                ds.put(message);

                long count = (Long) messageBoard.getProperty("count");
                ++count;
                messageBoard.setProperty("count", count);
                ds.put(messageBoard);

                log.info("Posting msg, updating count to " + count +
                         "; " + retries + " retries remaining");

                txn.commit();

                // Break out of retry loop.
                success = true;

            } catch (DatastoreFailureException e) {
View Full Code Here

     * @return 保存した管理者情報
     */
    public User put(String uid, String name, String mail,
            String phone, String zipcode, String address) {
        User result = null;
        Transaction tx = Datastore.beginTransaction();
        result = put(tx, uid, name, mail, phone, zipcode, address);

        tx.commit();

        return result;
    }
View Full Code Here

     * @param mail メールアドレス
     * @param manager 代表者
     * @return 保存したユーザ情報
     */
    public Editor put(String uid, String name, String mail, Manager manager) {
        Transaction tx = Datastore.beginTransaction();
        Editor result = put(tx, uid, name, mail, manager);

        tx.commit();

        return result;
    }
View Full Code Here

     * @param mail メールアドレス
     * @return 保存したユーザ情報
     */
    public User put(String uid, String name, String mail) {
        User result = null;
        Transaction tx = Datastore.beginTransaction();
        result = put(tx, uid, name, mail);

        tx.commit();

        return result;
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.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.