I have the following Objectify relation:
@Entity("Author")
public class Author{
@Id
private long authorId;
…
}
@Entity("Book")
public class Book{
@Id
private long id;
private Key<Author> authorKey;
…
}
Now for the fun part: I have authorId
(id, not entity), and I need to request a book for this author. My query is lower, but it returns an empty list, whereas I know that this author has books in the data warehouse. So how can I fix this request?
public static List<Book> getBooksForAuthor(Long authorId) {
Key<Author> authorKey = Key.create(Author.class, authorId);
return OfyService.ofy().load().type(Book.class).filter("authorKey", authorKey).order("-date").list();
}
source
share