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 6206317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:25:44+00:00 2026-05-24T05:25:44+00:00

I’ve been following the app engine JDO documentation as closely as possible, but I’m

  • 0

I’ve been following the app engine JDO documentation as closely as possible, but I’m having bizzare and inconsistent trouble loading a persistent collection that is contained by my Board object. The inconsistency occurs even in the local Development Webserver after I manually specify “eventual consistency” as being nonexistent.

Sometimes when I load my object/collection using the loading helper methods I’ve created, it loads no problem. Other times an empty collection is returned (please note that I am “touching” the collection with a getter method to ensure the data is not just a lazy loaded into a proxy object).

Initially I thought the problem was simply related due to the High Replication Storage engine’s “eventual consistency” drawbacks, but after making my own policy with 0% eventual consistency in the LocalServiceTestHelper, I’m fairly certain that’s not the case.

I’ve created a JUnit test that exemplifies this problem. Basically, I attempt to create and save a dummy User and Board object in the testInsertUser function. I attach a newly created ArrayList of PlayedTile objects to this board, and then execute a DataMaster.saveUser helper method which uses Google App Engine’s persistence manager to save the User (and thus the Board and PlayedTile collection) to the datastore. In the next method, we attempt to load that User (with its Board and PlayedTile collection) and display those saved results. Chaos ensues.

Here is the JUnit code:

package com.astar.wordswall.test.data;

import java.util.ArrayList;

import com.astar.wordswall.data.DataMaster;
import com.astar.wordswall.data.jdo.Board;
import com.astar.wordswall.data.jdo.User;
import com.astar.wordswall.data.jdo.PlayedTile;
import com.astar.wordswall.test.appengine.LocalCustomHighRepPolicy;
import com.google.appengine.api.datastore.Key;

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
// import com.google.gwt.user.client.Random;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class SaveUsersBoardWithTilesTest {

    Key userKey;

    private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
            .setAlternateHighRepJobPolicyClass(LocalCustomHighRepPolicy.class));

    @Before
    public void setUp() {
        helper.setUp();
    }

    @After
    public void tearDown() {
        helper.tearDown();
    }

    @Test
    public void testInsert1() {
        testInsertUser();
        testReadUser();
    }

    /**
     * Creation and insertion of a user, board, and linked set of tiles into BigTable.
     */
    private void testInsertUser() {
        User u = new User("Simon");
        Board b = new Board();
        ArrayList<PlayedTile> tiles = new ArrayList<PlayedTile>(7);

        u.setBoard(b);
        b.setPlayedTiles(tiles);

        for (int j = 0; j < 7; j++) tiles.add(new PlayedTile('T'));

        DataMaster.saveUser(u);
        // Retrieve the user's key so that we can read him from the database later
        userKey = u.getUserKey();

        // Display all of our saved tiles:
        System.out.println("Saved tiles:");
        // Note that "getTileString()" just iterates through each Played tile printing the letter
        System.out.println("\t" + u.getBoard().getTileString());
    }

    /**
     * A typical read of a user object from the Datastore.
     */
    private void testReadUser() {
        User u = DataMaster.getUserWithBoard(userKey);
        // Display all of our saved tiles:
        System.out.println("Loaded tiles:");
        System.out.println("\t" + u.getBoard().getTileString());
    }
}

And here’s the relevant DataMaster.getUserWithBoard static function that actually performs the JDO loading:

/**
 * Loads a uniquely specified User and their associated board from 
 * the Datastore.  It also loads the board's complete list of PlayedTiles.
 * @param userKey the unique key assigned to this user
 */
public static User getUserWithBoard(Key userKey){
    User u = null;
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try{
        u = pm.getObjectById(User.class, userKey);
        // In order for the board and tile collection to load, we must "touch" it while PM is active
        if (u.getBoard().getPlayedTiles().size() != 0) u.getBoard().getPlayedTiles().get(0);
        if (u.getBoard().getPlayedWords().size() != 0) u.getBoard().getPlayedWords().get(0);
    } finally{
        pm.close();
    }
    return u;
}

Oddly enough, this code SOMETIMES works as expected: it prints out the exact same set of tiles it saves after it loads them from the datastore in testReadUser(). SOMETIMES it just loads an empty collection, although what’s particularly bizzare is that the u.getBoard().getPlayedWords().get(0) call doesn’t throw a null pointer exception.

The output oscillates between

Correct:

Saved tiles:
    T T T T T T T 
Loaded tiles:
    T T T T T T T 

And Incorrect:

Saved tiles:
    T T T T T T T 
Loaded tiles:

totally haphazardly.

Can anybody out there shine some light on this? It’s driving me completely crazy. 🙂

EDIT: Another bizzare clue/factoid is that if I make the whole test iterate by enclosing both the testSaveUser and testReadUser method calls in a for loop, either EVERY load operations executes correctly, or NONE of them do. Is this a bug in the Local Google App Engine testing environment?

  • 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-24T05:25:46+00:00Added an answer on May 24, 2026 at 5:25 am

    Just to check: Did you mark your data classes as detachable? I.e.

    @PersistenceCapable(detachable = "true")
    public class Board { /* fun stuff here */ }
    

    Also, it might be helpful to look at the datastore viewer to see if really worked or not: http://localhost:8888/_ah/admin/

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a jquery bug and I've been looking for hours now, I can't
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.