How to make Keys-only query using JDO in Google App Engine Java

Varun   Varun 538 Views
Keys-only query using JDO

Sometime we just really need Ids from a particular entity but we lead to query full entity row, which is inefficient ....

GAE datastores support, query keys only lets see some basics....

Inorder to set Java Google App Engine JDO query into a keys-only query,
call setResult(String) as following to specify that only the @PrimaryKey column should be returned. 
JDO will convert this into a keys-only query on the datastore.

public class MyDatabaseEntity {
    private String name;
    // ...

Query q = pm.newQuery(MyDatabaseEntity.class);