Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5962609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:07:46+00:00 2026-05-22T19:07:46+00:00

I am not sure if I am understanding the google documentation, I am wondering

  • 0

I am not sure if I am understanding the google documentation, I am wondering if someone else can check my understanding.

Is the following code guaranteed to only ever do both of the following:

  • update to the bank account balance
  • store a record of the transaction.

Below is what I understand is correct:

public void add(String account, Double value, String description, Date date) throws EntityNotFoundException {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    int retries = 3;
    while (true) {
        Transaction txn = datastore.beginTransaction();
        try {

            // Update the bank balance
            Key key = KeyFactory.createKey("Account", account);
            Entity e = datastore.get(key);
            Double balance = (Double) e.getProperty("balance");
            balance += value;
            e.setProperty("balance", value);
            datastore.put(e);

            // Record transaction details
            Entity d = new Entity("Transaction", key);
            d.setProperty("account_key", key);
            d.setProperty("date", date);
            d.setProperty("value", value);
            d.setProperty("description", description);

            txn.commit();
            break;
        } catch (ConcurrentModificationException e) {
            if (retries == 0) throw e;
            retries--;
        } finally {
            if (txn.isActive()) txn.rollback();
        }
    }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:07:47+00:00Added an answer on May 22, 2026 at 7:07 pm

    That’s correct. It’s not necessary to include the key of the account in the entity, though – the entity you’re creating is a child of the account in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not quite sure I'm understanding how I can utilize generics in C# properly.
I just started tinkering with ASM and I'm not sure if my understanding of
I'm not sure if I'm completely understanding genetic algorithms and how they work, I'm
Not sure if this is a big deal. But wondering why when the site
What is polymorphism? I'm not sure I am understanding it correctly. In the Python
First, I'm not sure I really understand what a selector is. From my understanding,
I'm reading <<Understanding Linux Network internals>> ,but not sure how much of it will
I'm not sure if my understanding of C++ is wrong.. I've read that 1)
I am not sure about understanding about JSON, PHP, and MySQL. In my plan,
I am not sure about understanding about JSON, PHP, and MySQL. In my plan,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.