dae dae - 5 months ago 63
Java Question

Google Datastore Querys return stale data

I`m using Google App Engine and when I remove from the datastore and I list again the results, I recover stale data.
What is the problem?
Here is the code I use.

public void remove(long id) {
EntityManager em = EMFService.get().createEntityManager();
try {
Todo todo = em.find(Todo.class, id);
} finally {

public List<Todo> getTodos(String userId) {
EntityManager em = EMFService.get().createEntityManager();
Query q = em
.createQuery("select t from Todo t where t.author = :userId");
q.setParameter("userId", userId);
List<Todo> todos = q.getResultList();
System.out.println("Listado de " + userId + ": " + todos);
return todos;


AppEngine use HRD that is "eventually consistant.

Read more here: https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency