How to get data from a user from google storage?

I play with the Google engine and worry a bit about JDOQL queries .

This example shows how to retrieve data from a data store:

PersistenceManager pm = PMF.get().getPersistenceManager(); String query = "select from " + Greeting.class.getName(); List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute(); 

But what if I want to receive material only for this user?

The bottom of the page in the link above shows that we could be something like:

 select from guestbook.Greeting where author == ' alfred@example.com ' 

But if I try the following, it will not get anything:

 PersistenceManager pm = PMF.get().getPersistenceManager(); String query = "select from " + Greeting.class.getName() + " where author == '" + user.GetEmail() + "'"; List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute(); 

where user is retrieved, as shown in the same example, like this:

 UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); 

I'm sure this is a common task, but I just can't get it to work - any help is appreciated!

+1
source share
1 answer

After discussing this thread on Google Groups, I started working as follows:

 String select_query = "select from " + Greeting.class.getName(); Query query = pm.newQuery(select_query); query.setFilter("author == paramAuthor"); query.declareParameters("java.lang.String paramAuthor"); greetings = (List<Greeting>) query.execute(user); 

JDQL syntax is puzzled ...

+2
source

All Articles