1
votes

I am using App Engine (Java) with Objectify and RequestFactory.

My entity stores some fields and an embedded entity ArrayList. The embedded entity has its own couple of fields. So an example entity might look like:

name: Bob
email: [email protected]
todo.description: ["Pick up food", "Wash car", "Exercise"]
todo.importance: [1, 5, 3]

I have a DataGrid that pulls the embedded entity list and displays it. If you click a button a new item is added to the embedded entity, the entity persisted and the Data Grid is refreshed.

The problem is that it is not highly consistent. Most of the time the DataGrid will successfully refresh with the up to date data, but sometimes it just shows the old data and you will have to refresh the page to show the new results.

I understand that the App Engine is only eventually consistent when it comes to entities that are not in the same entity group, but as far as I understand an embedded entity just ends up as more fields on the entity containing it, i.e. there is only one entity involved, and everything should be highly consistent.

Am I wrong about this?

2
Just FYI, the term "embedded entity" is easily confused with the new Java low-level API EmbeddedEntity class. This is not the same as Objectify's @Embed/@Embedded objects - those aren't entities, just simple data structures embedded in the entity.stickfigure
@stickfigure Oops, thanks for pointing that out. And thanks for Objectify, it's awesome!Pixel Elephant

2 Answers

2
votes

http://code.google.com/p/googleappengine/issues/detail?id=6326

That is a thread from an issue I created. First, make sure you're turning on STRONG consistency (I believe eventual is the default).

Second - from that thread, here is an important note:

The strong consistency flag means that for e get by key or an entity group query, you will HAVE strong consistency with those constraints, but a "global" (entity root-less) query will still and always be eventually consistent. When you set the flag to EVENTUAL consistency, all queries will exhibit eventually consistent behavior.

So, if you're doing cross-entity queries, it may be EVENTUAL consistent, regardless of if you've set STRONG to default or not. So try turning on STRONG consistency, and then doing single get by key queries for all of the entities required to render your view, instead of a single query which is cross-entity.

1
votes

You can also issue an ancestor query and your query will be strongly consistent