Reputation: 23
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);
em.remove(todo);
} finally {
em.close();
}
}
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;
}
Upvotes: 2
Views: 297
Reputation: 6268
AppEngine use HRD that is "eventually consistant.
Read more here: https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency
Upvotes: 3