Objectify filter entities with parent key
<p>I have written a piece of code that fetches entities from google datastore by filtering the entity with the supplied parent key. When I run the code I am getting <code>java.lang.IllegalArgumentException</code>. </p>

<p>I know the problem is with the way I am creating the parent key, can you please guide me how to effectively create a parent key for this use case?</p>

<p>I am getting the below exception in <code>Myservice.java</code> line 8</p>

<pre><code>    Method threw 'java.lang.IllegalArgumentException' exception 
- Class hierarchy for class java.lang.Class has no @Entity annotation
</code></pre>

<p><strong>Appengine v1.9.36,
Objectify v5.1.7, 
JDK v1.7</strong></p>

<p>Below is a sample code</p>

<pre><code>import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;

    @Entity
    @Cache
    public class ParentEntity {

        @Id
        Long id;

        String name;

        String value;

        public static Key&lt;ParentEntity&gt; getKey(Long id){
            return Key.create(ParentEntity.class, id);
        }

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
</code></pre>

<p>Another entity class</p>

<pre><code>import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent;

@Entity
@Cache
public class ChildEntity {

    @Id
    Long id;

    @Parent Key&lt;ParentEntity&gt; application;

    String city;

    public static Key&lt;ChildEntity&gt; getKey(Long id){
        return Key.create(Key.create(ParentEntity.class), ChildEntity.class, id);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Key&lt;ParentEntity&gt; getApplication() {
        return application;
    }

    public void setApplication(Key&lt;ParentEntity&gt; application) {
        this.application = application;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }
}
</code></pre>

<p>ServiceLaver that uses Objectify to fetch entities</p>

<pre><code>import java.util.List;
import com.googlecode.objectify.ObjectifyService;

public class MyService{

    public List&lt;ChildEntity&gt; filterByID(Long id){
        return ObjectifyService.ofy().load().type(ChildEntity.class)
            .filterKey(ChildEntity.getKey(id)).first().now();
    }
}
</code></pre>