Try this :

Query q = pm.newQuery(People.class);
q.setFilter("contactmethods.contains(pContactMethod)");
q.declareParameters("com.google.appengine.api.datastore.Key
pContactMethod");
List<People> allPeople = (List<People>)q.execute(lContactMethodKey);

Bye.

On 15/09/10 20:28, "Shaun" <[email protected]> wrote:

> I have two entities:
> 
> public class People {
> 
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
> 
> @Persistent
> private List<Key> contactmethods;
> }
> 
> public class ContactMethod {
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
> 
> @Persistent
> private String contactmethodaddress;
> }
> 
> Every time I add a new contact method, i.e. phone number, email, etc I
> add an entry into the person's list so we know all of the ways we can
> contact them. Now, I want to find out who a person is based on one of
> those entries.
> 
> So if I have the key for a specific contactmethod, how do I select the
> Person(s) to which it belongs? I have tried:
> 
> javax.jdo.Query q = pm.newQuery(People.class);
> q.setFilter("this.contactmethods.contains(pContactMethod)"); and
> q.setFilter("contactmethods == pContactMethod");
> q.declareImports("import com.google.appengine.api.datastore.Key");
> q.declareParameters("Key pContactMethod");
> List<People> allPeople = (List<People>)
> pm.newQuery(q).execute(lContactMethodKey);
> 
> Where lContactMethodKey is the Key of the contact method being
> searched for.
> 
> either way I get:
> 
> javax.jdo.JDOFatalUserException: Exception converting
> com.appointment.datastoreobjects.peo...@2c453c47 to an internal key.
> Received a request to find an object of type
> com.appointment.datastoreobjects.People identified by
> com.appointment.datastoreobjects.peo...@2c453c47.  This is not a valid
> representation of a primary key for an instance of
> com.appointment.datastoreobjects.People.
> 
> Thanks for any insight you can give!
> Shaun
> 
> 



-- 
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.

Reply via email to