How can I set the ID for an entity? for inserting I create a Key and an 
entity:

Key collectionData = KeyFactory.createKey("FinalCount", "FinalCollection");
     Entity countData = new Entity("Final", collectionData);

but for set the ID I don't know how, do you have examples?

Thank you.

El miércoles, 5 de febrero de 2014 19:01:49 UTC-6, Vinny P escribió:
>
> On Wed, Feb 5, 2014 at 10:35 AM, Juan de Dios Becerra 
> <j.bece...@gmail.com<javascript:>
> > wrote:
>>
>> I have not found a good example of how to update datastore, so I am doing 
>> manually delete the entities and then insert again I know is completely 
>> awful for this reason I think it could be a better way, there exists? Btw I 
>> am using Java.
>>
>  
>
> Hi Juan,
>
> In the App Engine datastore, an update operation is the same as an insert 
> operation; if you insert an entity with the same Kind and ID/Name as a 
> currently existing entity, the pre-existing entity will be overwritten with 
> information from the new entity. Also, the indexes will be automatically 
> updated to reflect the new values. 
>
> So you can simply reuse the code that is currently doing the entity 
> insertion. Just remember to set the same Kind and ID/Name as the entity you 
> want to overwrite. If you don't know the current IDs in use, you can query 
> for the entities and extract the IDs.
>   
>  
> -----------------
> -Vinny P
> Technology & Media Advisor
> Chicago, IL
>
> App Engine Code Samples: http://www.learntogoogleit.com
>  
>

-- 
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 http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to