> Can you post the JPA version of your entity?

@Entity
public class Friend {


  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Key key;

  private String lastName;

  public int crud;

  private String firstName;

  @Basic
  private Collection<Key> friends;


> I've just built something similar, and if I pass a Key to:
>
>             query.setParameter("key", key);
>
> This works correctly, though if I pass the String key to it
>
>             query.setParameter("key", "someLongString");


what was ur query? was the query to filter on a collection?
i have set the parameters against primitive members successfully but
not against collection members.

> It returns an empty list. Could this be what is happening?

no.i just retested my code to make sure i hadnt messed up. i am
definitely using a Key not a string.

//JPA
javax.persistence.Query query = em.createQuery("select from Friend f
where f.friends=:key");
query.setParameter("key", user2.getKey());

return list of 0

using the *same* JPA entity code the JDO works fine

//JDO
javax.jdo.Query query = pm.newQuery(Friend.class);
Key myKey = user2.getKey();
query.declareParameters("com.google.appengine.api.datastore.Key
myKey");
query.setFilter("friends == myKey");
query.setOrdering("lastName ASC, firstName ASC");
List<Friend> friendList = (List<Friend>) query.execute(myKey);

return correct list

Q1 can u post your JPA code so i can see what u have done differently?

Q2. is mixing JPA and JDO ok? ie. JPA entity and JDO seems to work for
me.

Q3.how does the collection equality filter work in app engine? I have
not found any docs to explain the 'voodoo' like behaviour.
from what i can determine the collection filter is executed on the
data store and not in the application as the unfiltered list executed
the 1000 row limit.
it works but i dont understand how.

any help most appreciated

-lp

--

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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=.


Reply via email to