Having a unique id that is only a property and not the key of the entity 
makes it hard.
Are you generating the ID - is it sequential, or just unique (ie an email 
address) if the later, you could reliably use a combination of transactions 
and a child entity with a key of the unique id, and the ancestors key).

You don't even have store any data.

This can be reliable as you are able to use get operations in a transaction.

Anything entity you fetch by a query (unless it's an ancestor query) will 
be liable to eventual consistancy issues.

T

On Wednesday, January 27, 2016 at 7:39:54 PM UTC+8, Louise Elmose Hedegaard 
wrote:
>
>
> Hi,
>
> I have an issue with too many entities being created in my GAE datastore. 
>
> I have an unique id on an entity (which is not the key in this case), and 
> there should thus only be one entity in the datastore per unique id.
> When an entity is updated or created by the user, I check whether the 
> entity already exists in the DB, and only create a new entity, if there is 
> not already an existing entity with a matching id. If there is an existing 
> entity, I update the parameters of the entity.
> This logic should ensure that there is only one entry/entity per unique 
> id, but somehow several entities with the same id are created in the DB - I 
> do not understand how/why!
>
> When I look at this page 
> https://cloud.google.com/appengine/docs/java/datastore/entities#Java_Updating_an_entity
>  
> is says "You can use a transaction 
> <https://cloud.google.com/appengine/docs/java/datastore/transactions> to 
> test whether an entity with a given key exists before creating one.".
>
> Do I really need to use transactions to validate whether there is an 
> existing entity with a given id, or does that only apply when you use the 
> key as primary key??
>
> Thanks,
> -Louise
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/fc9c1861-f446-42fe-8fbb-bbd884ed5be1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to