jdo

Google App Engine Error: No matching index found. (Java)

坚强是说给别人听的谎言 提交于 2019-12-06 14:41:08
问题 I am writing a query but it always says "No matching index found". I don't know why. My code is as below: Query query = pm.newQuery(Classified.class); query.setFilter("emp_Id == emp"); query.setOrdering("upload_date desc"); query.declareParameters("String emp"); List<Classified> results = (List<Classified>)query.execute(session.getAttribute("emp_Id").toString()); <?xml version="1.0" encoding="utf-8"?> <datastore-indexes autoGenerate="true"> <datastore-index kind="Classified" ancestor="false">

Set an entity kind name different from a class name

丶灬走出姿态 提交于 2019-12-06 11:58:39
问题 Is there any way how to set a kind name different from a class name used in my Google App Engine? I am using Java and JDO to access a datastore. There a question about the similar issue in Python. It seems answered. Set a kind name independently of the model name (App Engine datastore) 回答1: Ooops... It was quite easy to achieve: @PersistenceCapable(table = "person") public class PersonEntity { // ... } 来源: https://stackoverflow.com/questions/7616158/set-an-entity-kind-name-different-from-a

On Google App Engine (GAE), how do I search on the Key/ID field?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 09:21:02
I've got this code (Java, GAE): // Much earlier: playerKey = KeyFactory.keyToString(somePlayer.key); // Then, later... PersistenceManager pm = assassin.PMF.get().getPersistenceManager(); Key targetKey = KeyFactory.stringToKey(playerKey); Query query = pm.newQuery(Player.class); query.setFilter("__key__ == keyParam"); query.declareParameters("com.google.appengine.api.datastore.Key keyParam"); List<Player> players = (List<Player>) query.execute(targetKey); // <-- line 200 which generates this error: javax.jdo.JDOFatalUserException: Unexpected expression type while parsing query. Are you certain

How to dynamically build JDO Queries on multiple parameters

有些话、适合烂在心里 提交于 2019-12-06 04:16:02
问题 One can easily use JDO syntax to query on multiple parameters as follows: //specify the persistent entity you're querying and you filter usign params query = pm.newQuery(MyClass.class, " customer == paramCustomer && date >= paramStartDate && date <=paramEndDate "); // declare params used above query.declareParameters("com.google.appengine.api.users.User paramCustomer, java.util.Date paramStartDate, java.util.Date paramEndDate"); //pass the object declared as params MyClassList = (List<MyClass

Google Datastore - Problems updating entity

那年仲夏 提交于 2019-12-06 03:47:53
I am dusting off my google app-engine / datastore skills ... and getting stuck on something very simple. As per the example on the GAE documentation I am trying to update an entity as follows: // persistence and business logic PersistenceManager pm = PMF.get().getPersistenceManager(); // get it NickName n = pm.getObjectById(NickName.class, nicknameId); // update fields n.givenName = "new name"; n.nickName = "new nickname"; n.timeStamp = new Date(); // close manager to persist changes pm.close(); This doesn't work (as in the changes are not persisted, but no errors or anything else)! At the

Problems while saving a pre-persisted object in Google App Engine (Java)

北城以北 提交于 2019-12-05 22:33:08
I am having problems while saving a pre-persisted JDO object in google-app-engine data store. Basically, in one servlet, I create the object and save it. In another servlet, I read the object, set a bunch of properties and try updating it. The update is through a makePersistent call on PersistenceManager . There is no exception being thrown and no warning logs. However, when I access the same object later, its still in its original state. The PersistenceManager is never closed between the read and the update (as suggested in the Datastore documentation ) The only thing that might be different

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

Set an entity kind name different from a class name

拟墨画扇 提交于 2019-12-04 17:27:25
Is there any way how to set a kind name different from a class name used in my Google App Engine? I am using Java and JDO to access a datastore. There a question about the similar issue in Python. It seems answered. Set a kind name independently of the model name (App Engine datastore) Ooops... It was quite easy to achieve: @PersistenceCapable(table = "person") public class PersonEntity { // ... } 来源: https://stackoverflow.com/questions/7616158/set-an-entity-kind-name-different-from-a-class-name

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