Yes, but I don't see where to associate the ID, when I create my entities I 
use only one key for all the entities, see this snippet:

Key activityData = KeyFactory.createKey("Activity", "ActivityData");

for(int a = 0 a < activities.size(); a++){
    Entity activityDesglose = new Entity("Activities", activityData);
    activityDesglose.setProperty("publishDate", date);
    activityDesglose.setProperty("title", activities.get(i).getTitle());
    activityDesglose.setProperty("type", activities.get(i).getVerb());
}

I don't know if I explain my point correctly, where or how con I use the ID 
to get the correct entity.

El jueves, 6 de febrero de 2014 17:43:51 UTC-6, PK escribió:
>
> There is a get() method where you pass the key and get the entity back. 
> This is described in the docs here: 
>
> https://developers.google.com/appengine/docs/java/datastore/entities
>
> Retrieving an entity
>
> To retrieve an entity identified by a given key, pass the 
> Key<https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Key>
>  object 
> to the 
> DatastoreService.get()<https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService#get(com.google.appengine.api.datastore.Key)>
>  method:
>
> // Key employeeKey = ...;
> Entity employee = datastore.get(employeeKey);
>
>
> PK
> http://www.gae123.com
>
> On February 6, 2014 at 3:06:22 PM, Juan de Dios Becerra (
> [email protected] <javascript:>) wrote:
>
> 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 <
>> [email protected]> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/google-appengine.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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