samedi 5 avril 2014

Problems with Google Endpoint Querying my Datastore


Vote count:

0




I am learning to write my own queries for the Google Datastore. I either get 0 results when their should be, or an error. I am passing in the data as a string with the email address I am looking for.



@SuppressWarnings("unchecked")
@ApiMethod(name = "findByEmail")
public User findByEmail(@Named("emailReq") String emailReq) {
PersistenceManager mgr = null;
List<User> users = null;
Query query = null;

try {
mgr = getPersistenceManager();
query = mgr.newQuery(User.class);
query.setFilter("email=='emailReq'");
query.declareParameters("String email");
query.declareVariables(emailReq);
users = (List<User>) query.execute(emailReq);

}finally {
query.closeAll();
}
return users.get(0);
}


asked 56 secs ago






Aucun commentaire:

Enregistrer un commentaire