Reputation: 1650
I am having problem with filtering the entities after addFilter() has been
deprecated from Google App Engine .
Objective : to list those Entities which are having UID = "rahul"
what i tried :
com.google.appengine.api.datastore.DatastoreService ds=DatastoreServiceFactory.getDatastoreService();
Query q = new Query("Upload");
q.setFilter(FilterOperator.EQUAL.of("UID","rahul"));
PreparedQuery pq = ds.prepare(q);
for (Entity result : pq.asIterable())
{
String title = (String) result.getProperty("url");
resp.getWriter().println(title);
}
And this is my DataStore Instance for "Upload" Entity :
But, I am getting a blank page when launching the app .
Upvotes: 2
Views: 3714
Reputation: 1245
As addFilter()
is deprecated, you may also use following code:
To create a single filter:
query.setFilter(new Query.FilterPredicate("UID", FilterOperator.EQUAL, "rahul"));
To create multiple filters:
After you build all of your filters, combine them together using a CompositeFilter:
new CompositeFilter(CompositeFilterOperator.AND, Arrays.asList(filter1, filter2));
Then set it as the filter to your query by writing:
query.setFilter(composite_filter);
Upvotes: 2
Reputation: 1289
It should give the desired output. If it is giving blank page then kindly check logs in Google Dashboard or shared logs.
Upvotes: 0