Can you post the JPA version of your entity? Filtered queries should work on
JPA objects, but just for a sanity check let's see if there's anything that
jumps out at us.

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");

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


On Thu, Nov 19, 2009 at 9:26 PM, lp <lucio.picc...@gmail.com> wrote:

> hi all,
>
> i have a JDO query that i would like to port to JPA.
>
> Friend Entity
> @PersistenceCapable(identityType=IdentityType.APPLICATION)
> public class Friend {
>
>  @PrimaryKey
>  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>  private Key key;
>
>  @Persistent
>  private String lastName;
>
>  @Persistent
>  public int crud;
>
>  @Persistent
>  private String firstName;
>
>  @Persistent(defaultFetchGroup = "true")
>  private Collection<Key> friends;
>
>
> //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("crud ASC, lastName ASC, firstName ASC");
>     List<Friend> friendList = (List<Friend>) query.execute(myKey);
>
>
> The problem i am having is with the query.setFilter("friends ==
> myKey" ) portion.
>
>   //JPA
>      javax.persistence.Query query = em.createQuery("select from
> Friend where friends=:key");
>      query.setParameter("key", user2.getKey());
>      List<Friend> friendList = (List<Friend>) query.getResultList();
>
> however the resultlist returns 0.
>
> any help is 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<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

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