Key Filtering in the App Engine Data Warehouse in Java

You would think that this would be a simple question to answer.

How do I, in Java, filter an entity key (not a property that simply has a Key type, but its actual key - what will we call the "primary key" in the ground of a relational database)?

I do not want to receive any objects with a specific key. I really want to make a filter and return a subset of objects.

+4
source share
1 answer

The trick is to use Entity.KEY_RESERVED_PROPERTY instead of the property name:

 Query q = new Query("MyEntity"); q.setFilter(new Query.FilterPredicate(Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.GREATER_THAN, KeyFactory.createKey("MyEntity", "somevalue"))); 

All MyEntity entities with a key greater than somevalue will be found somevalue .

+8
source

Source: https://habr.com/ru/post/1432727/


All Articles