If you're using com.google.appengine.api.datastore.Key for your primary keys,
it has a getParent() method which returns null when the object doesn't have a
parent. Also, your code is fetching a List of Entity, and Entity also has a
getParent() which returns null if there is no parent.
m seleron wrote:
> Sorry, did not have enough explanation.
>
> I corrected it a little.
>
> I think that the method of confirming the parent existence is simple.
> It uses Entity#getParent()
>
> How about the following examples?
>
> String parentKindName = "parentKind"; //Parent Kindname
> String kindName = "kindName"; // Child Kindname
>
> DatastoreService service = DatastoreServiceFactory.getDatastoreService
> ();
>
> Query query = new Query(kindName);
> PreparedQuery pq = service.prepare(query);
> List<Entity> list = pq.asList(FetchOptions.Builder.withOffset(0));
>
> for (Entity e : list) {
> e.getProperty("xx"); //get childproperty
> ....
>
>
> //Parent check
> PreparedQuery parentPq = service.prepare(new Query
> (parentKindName,e.getParent()));
> int parentCount = parentPq.countEntities();
> if (parentCount == 0){
> //abandoned children
> }
>
> }
>
> Please try.
> Thanks,
> seleronm
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.