jdoql

How to fetch data by user from google datastore?

I am playing with google app engine and having a bit of trouble on JDOQL queries. The example shows how to fetch stuff from the datastore: PersistenceManager pm = PMF.get().getPersistenceManager(); String query = "select from " + Greeting.class.getName(); List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute(); But w...

App Engine datastore does not support operator OR

I am trying to query the google datastore for something like (with pm --> persistanceManager): String filters = "( field == 'value' || field == 'anotherValue' )"; Query query = pm.newQuery(myType.class, filters); When I execute - I am getting back: App Engine datastore does not support operator OR. What's the best approach in peop...

Google Datastore problem with query on *User* type

On this question I solved the problem of querying Google Datastore to retrieve stuff by user (com.google.appengine.api.users.User) like this: User user = userService.getCurrentUser(); String select_query = "select from " + Greeting.class.getName(); Query query = pm.newQuery(select_query); query.setFilter("author == paramAuthor"); que...

Why am I getting a cast error in my Query using JDO on Google App Engine?

According to the Queries and Indexes doc you can go a query effectively identically (so far as I can tell) to this: PersistenceManager pm = PMF.get().getPersistenceManager(); try { Query q = pm.newQuery(App.class); q.setOrdering("name desc"); try { results = (ArrayList<App>) q.execute(); } finally { q.closeAll(); } } finally {...

Can I do a text search against a pattern when using Google App Engine?

All examples I'm seeing show how to pull up entities matching a string exactly. Is there an equivalent to a LIKE query? Also, if it helps, I'm thinking of using the result for an auto-completing a text box. Thanks ...

GAE Datastore and security risks with JDOQL

I just started working on a project that will run on google app engine (GAE). I'm using java (wicket) with some ajax. I'm experienced with relational databases and typically use something like iBatis. When going through the docs and examples for the GAE datastore using JDO I see that they're executing stuff like: String query = "sele...

JDO for Google App Engine: escaping quotes

How do I escape parameters of queries in JDO (Google App Engine)? For example, how do I make the next snippet safe, if the variable name may contain unsafe chars as single quotes (') PersistenceManager pm = ...; String query = "select from Person where name='"+name+"'"; List<Shortened> shortened = (List<Shortened>) pm.newQuery(query).e...

Filter a date property between a begin and end Dates with JDOQL

I want to code a function to get a list of Entry objects whose date field is between a beginPeriod and endPeriod I post below a code snippet which works with a HACK. I have to substract a day from the begin period date. It seems the condition great or equal does not work. Any idea why I have this issue? public static List<Entry> getEnt...

Persistance JDO - How to query a property of a collection with JDOQL?

I want to build an application where a user identified by an email address can have several application accounts. Each account can have one o more users. I am trying to use the JDO Storage capabilities with Google App Engine Java. Here is my attempt: @PersistenceCapable @Inheritance(strategy = InheritanceStrategy.NEW_TABLE) public class...

Store java.util.Calendar field into one column

How to store java.util.Calendar field into one column with Datanucleus JDO. By default it is stored into two columns (millisecs, Timezone) with following JDO metadata. field name="startDate" serialized="true" embedded="true" persistence-modifier="persistent" What need to be changed in metadata to sto...

How to retrieve a list of objects which are a property of a class with JDOQL?

I have the next persistence capable classes: @PersistenceCapable public class AppAccount { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private String companyName; @Persistent List<AppUser> users = new ArrayList<AppUser>(); // Getters and Sett...

How to do batch Google DataStore key lookup query in JDO

I have about 50k entities stored in appengine. I am able to look up an individual record via the GQL admin interface with a query like: SELECT * FROM Pet where __key__ = KEY( 'Pet','Fido') But I'm having trouble figuring out how to do a batch version of this via JDO. Right now I have this: PersistenceManager pm = ...; for(...

Query by datetime in JDOQL / Java / GAE

I'm working on a GAE app. I want to query datastore and retrieve all records between startDate and endDate. Each record has a datetime field. I'm using a query similar to this (the below code is something I quickly grabbed - I'm not near my developer machine.): Query query = pm.newQuery(Employee.class); query.setFilter("lastName == las...

JDOQL Any way to avoid multiple .contains() calls in the query when searching for the presence of one or more elements in a member List variable?

The question pretty much says it all. If I have a class Class A public class A { ... private List<String> keys; ... } And I want to select all A instances from the DataStore that have atleast one of a List of keys, is there a better way of doing it than this: query = pm.newQuery(A.class); query.setFilter("keys.contains(:...

JDOQL (datanucleus) query compiling error in GregorianCalendar field

Following query gives a NullPointerException when complie it. Query query = pm.newQuery(Festival.class); query.setFilter("this.startDate == sDate"); query.declareImports("import java.util.GregorianCalendar"); query.declareParameters("GregorianCalendar sDate"); query.compile(); Class: public class Festival{ ... private G...

Subqueries on Java GAE Datastore

I am trying to create a database of users with connection between users (friends list). There are 2 main tables: UserEntity (main field id) and FriendEntity with fields: - initiatorId - id of user who initiated the friendship - friendId - id of user who has been invited. Now I am trying to fetch all friends of one particular user and ...

How to delete specific record from Google Datastore (in Java) ?

I have some records in datastore, I want to delete a specific record from the table. for example in SQL , we use delete * from table1 where name ="mike" what is the equivalent code in java (I m using Eclipse with Google appengine API plugin)? or any other method to do that? ...

AppEngine JDO-QL : Problem with multiple AND and OR in query

Hi, I'm working with App Engine(Java/JDO) and are trying to do some querying with lists. So I have the following class: @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class MyEntity { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key key; @Persistent List<Strin...

Java: JDOQL startsWith query, case sensitive

I'm using the .startsWith() filter in a JDOQL query but it's case sensitive. So startsWith("ab") doesn't return "Abc" result and so on. Will I need to use a SQL query to avoid this ? ...

Declarative JDOQL vs Single-String JDOQL : performance

When querying with JDOQL is there a performance difference between using the declarative version and the Single-String version: Example from the JDOQL doc: //Declarative JDOQL : Query q = pm.newQuery(org.jpox.Person.class, "lastName == \"Jones\" && age < age_limit"); q.declareParameters("double age_limit"); List results = (List)q.execu...