Using GQL queries in App Engine Datastore with Java

103 views
Skip to first unread message

Shubhashis Karmakar

unread,
Jan 24, 2015, 2:11:59 AM1/24/15
to google-a...@googlegroups.com

While working with datastore I saw that all the queries in the datastore are parsed in the format SELECT * FROM kind WHERE property = someValue. I was working with Android Studio and while debugging I saw it. Also you can run this type of query on the app server.

Later I came to learn that it was called GQL. I searched stackoverflow for proper implementation but in every post I found that GQL queries on Java is not supported. However, it can be done via 3rd party tools. So I looked at official documentation here.

Now here I saw a code snippet in Java. But when i tried to implement it, it does not work. I mean the code does not even compile let alone work. There are compilation errors.

Even the line 
import static com.google.apphosting.client.datastoreservice.client.DatastoreHelper.*; which you will find on protocol buffers in Java Section does not work.

Now is the official documentation faulty? Or I am making a mistake?

I am looking for a simple implementation on GQL queries on java and so far I have not found any solution. I am using Android Studio.

I know about datastore queries and implemented them with Android Studio. I am NOT looking for any alternatives for GQL queries. If anyone has any working solution on GQL queries on java, please help.

Vinny P

unread,
Jan 27, 2015, 2:11:52 AM1/27/15
to google-a...@googlegroups.com
On Sat, Jan 24, 2015 at 1:11 AM, Shubhashis Karmakar <shubh...@gmail.com> wrote:

Even the line 

import static com.google.apphosting.client.datastoreservice.client.DatastoreHelper.*; which you will find on protocol buffers in Java Section does not work.



Are you talking about this page? It does work, but you need to include the Cloud Datastore library: https://developers.google.com/api-client-library/java/apis/datastore/v1beta2

But a word of warning: accessing the datastore through the standard App Engine libraries is more direct (read: faster) than piping through the Cloud Datastore service. If you want to optimize your app, you should forget the GQL and use the low-level library or abstractions such as Objectify.
 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

Reply all
Reply to author
Forward
0 new messages