You want to store the Key of the User not the actual User. If you
store the User you are creating an owned relationship. This means
that the user can only be owned by one book. What you want is an
unowned relationship, which means storing the keys. Then your query
stays the same except you will need to add query.import("import Key")
<--- not the exact syntax
On Feb 6, 5:04 pm, Arjan <[email protected]> wrote:
> Hi all,
> It seems like i am doing this the wrong way and the datastore is giving me a
> hard time making queries.
> I've got a my own User class in my application and there is a Book class in
> the application.
> Now the Book class has an owner and a write attribute.
> @Entity
> class User {
> @Id
> private String email;
>
> }
>
> @Entity
> class Book {
> @Id
> @GeneratedValue(strategy = GenerationType.IDENTITY)
> private Key key;
> private User owner;
> private User writer;
>
> }
>
> I want to search the store for all owned books (on the users myPage)
> Query query = getEntityManager().createQuery("SELECT b FROM Book b WHERE
> b.owner == :owner");
> query.setParameter("owner", owner);
>
> List<Book> books = query.getResultList();
>
> Now the datastore is throwing ugly things to me like "Key of parameter value
> does not have a parent."
>
> I'm realy lost here. Could anyone explain to me how i could solve this?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.