jdoql

JDOQL DATANUCLEUS filtering using String matches

爷,独闯天下 提交于 2020-01-01 19:41:17
问题 Using JDO with Datanucleus, I'm trying to filter some data from my database (using jdoql). I would like to use the regular expression for some sophisticated searchs, I found that JDO provide the String method "matches" that accepts a regular expression, and according to the DATANUCLEUS documentation, this method can receive any type of ExpReg: matches(String pattern) : Returns whether string matches the passed expression. The pattern argument follows the rules of java.lang.String.matches

What does “:P” mean in a JDO query

 ̄綄美尐妖づ 提交于 2019-12-22 10:48:35
问题 I am using JDO on google app engine. Each 'Employee' has a 'key'. I have a set of keys and wanted to retrieve all Employees whose key belongs to this set. So I implemented it using the 'contains()' filter as specified here. The code works fine and looks like this - List<Key> keys = getLookupKeys(....) ..//Get keys from somewhere. Query query = pm.newQuery(Employee.class,":p.contains(key)"); //What is ":P" here? List<Employee> employees = (List<Employee>) q.execute(keys); //This correctly

JDO for Google App Engine: escaping quotes

半世苍凉 提交于 2019-12-22 07:03:59
问题 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).execute(); 回答1: Use query parameters instead, it's a much safer than including the values in the query itself. Here is an example from the GAE documentation:

JDO for Google App Engine: escaping quotes

岁酱吖の 提交于 2019-12-05 12:09:36
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).execute(); Use query parameters instead, it's a much safer than including the values in the query itself. Here is an example from the GAE documentation: Query query = pm.newQuery("select from Employee " + "where lastName == lastNameParam " + "order by hireDate

JDOQL DATANUCLEUS filtering using String matches

感情迁移 提交于 2019-12-04 19:24:34
Using JDO with Datanucleus, I'm trying to filter some data from my database (using jdoql). I would like to use the regular expression for some sophisticated searchs, I found that JDO provide the String method "matches" that accepts a regular expression, and according to the DATANUCLEUS documentation, this method can receive any type of ExpReg: matches(String pattern) : Returns whether string matches the passed expression. The pattern argument follows the rules of java.lang.String.matches method. I was able to do filtering based on some regular expression (like " .* ", ".", ". * ") But not with

Google Datastore problem with query on *User* type

…衆ロ難τιáo~ 提交于 2019-12-04 15:56:50
问题 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"); query.declareParameters("java.lang.String paramAuthor"); greetings = (List<Greeting>) query.execute(user); The above works fine - but after a bit of messing around I

App Engine datastore does not support operator OR

牧云@^-^@ 提交于 2019-11-27 15:21:39
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 people experience for this kind of queries? Any help appreciated! Perform multiple queries. The Datastore, like all other databases, isn't able to efficiently execute disjunctions. Unlike other databases, it exposes this difficulty to the user, to make it clear that what

App Engine datastore does not support operator OR

牧云@^-^@ 提交于 2019-11-26 17:07:49
问题 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 people experience for this kind of queries? Any help appreciated! 回答1: Perform multiple queries. The Datastore, like all other databases, isn't able to efficiently