Filter Query Results With Objectify

Table of contents
Reading Time: < 1 minute

Objectify is a Java data access API specifically designed for the Google App Engine datastore.
It is an easy way to use Google Datastore.

In this blog we are going to filter a single attribute for multiple values.

Now lets start with creating an entity.
The first step is to define your entity class. Here is an example of employee.


Now before applying any datastore operation, we must register all our classes with the objectifyservice.

Basic operations in objectify are: Get, Put and Delete.

We can obtain an Objectify interface from the ObjectifyService:

Now our final step is querying
Every time you load() an Employee, it will fetch the entire list.
Large numbers of data will bloat the entity and impact performance.
Lets start with

This statement will show all the employee name started with john.

With Objectify, you have the option to use the in operator in a query

IN operator performs multiple queries, one for each item in the
specified list. The results are merged, in the order of the items in the list.
For instance,

1 thought on “Filter Query Results With Objectify2 min read

Comments are closed.