Here is the native datastore query for your problem if you want to try it 
out:

        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        Query query = new Query(Member.class.getSimpleName());
        query.setFilter(new FilterPredicate("name", FilterOperator.EQUAL, 
nameParam));
        List<Entity> list = 
ds.prepare(query).asList(FetchOptions.Builder.withDefaults());

In my opinion, if you are building a new application right now, you should 
consider other options on accessing the Datastore, such as Objectify 
<https://code.google.com/p/objectify-appengine/> or even the raw Datastore 
API. JDO is pretty heavyweight for the App Engine model.

On Sunday, December 7, 2014 7:12:47 AM UTC-2, ajg...@gmail.com wrote:
>
>
> Hello,
>
> I am using eclipse+google plugin to develop a simple API with Cloud 
> Endpoints. I just have a member entity with JDO annotations, and I 
> generated the Endpoint class.
>
>
> My Member entity only has 2 fields: the Long id and String name.
> I would like to use a getMemberByName(String name) method to retrieve 
> easily a member instead of having to know its id.
>
> So I added this method to the Endpoint class generated:
>
>
> @SuppressWarnings({“unchecked”})
>
>
>
> @ApiMethod(name = “getMemberByName”,path=”/member/byname/{name}”)
>
> public List getMemberByName(@Named(“name”) String name) {
>
> PersistenceManager mgr = getPersistenceManager();
>
> List candidates = null;
>
> Query q=mgr.newQuery(Member.class);
>
> q.setFilter(“name == nameParam”);
>
> q.declareParameters(“String nameParam”);
>
> try {
>
> candidates = (List) q.execute(nom);
>
> } finally {
>
> mgr.close();
>
> }
>
> return candidates;
>
> }
>
>
> When I call this API method and give it a name parameter (which does exist 
> in my datastore) it sends me nothing back but a 404 error. 
>
> I thought maybe you could tell me if my code got any error, I’m not an 
> expert with JDO.
>
>
> Thank you.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to