简体   繁体   English

更新Google App Engine的DataStore中的查询-Java

[英]Update query in DataStore of google app engine - java

I am newbie to app engine. 我是App Engine的新手。 I want to update some fields of my entity in datastore. 我想更新数据存储区中实体的某些字段。 For that i have created query like below but neither it updates my entity nor throws error. 为此,我创建了如下query ,但它既不会更新我的实体也不会引发错误。 I don't know where i am going wrong.I referred this SO post but i have huge collection of data. 我不知道我要去哪里错。我提到了这篇文章,但我收集了大量数据。 Therefor, for me, its very hard to fetch hundreds of records and persist them.Please help me to solve this problem. 因此,对我来说,很难获取数百条记录并保留它们。请帮助我解决此问题。

Code: 码:

@ApiMethod(name = "updateUserProfile", httpMethod = HttpMethod.GET, path = "userfeedmasterendpoint/updateProfile")
public void updateUserProfile(@Named("userName") String uName,
            @Named("uAbout") String userAbout) 
    {
       EntityManager mgr = null;
       try {
                mgr = getEntityManager();
                Query query = mgr
                        .createQuery("update UserFeedMaster u set u.userAbout = :uAbout where u.userName=:userName");
                query.setParameter("userName", uName);
                query.setParameter("uAbout", userAbout);
                query.executeUpdate();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return;
       }

A query will only ask the datastore for a set of object satisfying a criteria and retrieve these. 查询将仅向数据存储区询问一组满足条件的对象,然后检索这些对象。 To update an object you need to retrieve it (with a query for instance), update this object and then put it back in the datastore (by calling your ORM put method). 要更新对象,您需要检索它(例如,使用查询),请更新该对象,然后将其放回数据存储中(通过调用ORM put方法)。

If you are new to AppEngine and you want to use the datastore in an easy way, you should look at Objectify. 如果您不熟悉AppEngine,并且想以简单的方式使用数据存储,则应查看Objectify。 It is a java ORM for the Datastore. 它是数据存储区的Java ORM。 Here is a short description of the project : 这是该项目的简短说明:

Objectify is a Java data access API specifically designed for the Google App Engine datastore. Objectify是专门为Google App Engine数据存储区设计的Java数据访问API。 It occupies a "middle ground"; 它占据了“中间地带”。 easier to use and more transparent than JDO or JPA, but significantly more convenient than the Low-Level API. 与JDO或JPA相比,它更易于使用且更加透明,但比Low-Level API更加方便。 Objectify is designed to make novices immediately productive yet also expose the full power of the GAE datastore. Objectify旨在使新手立即提高工作效率,同时也展现GAE数据存储的全部功能。

https://code.google.com/p/objectify-appengine/ https://code.google.com/p/objectify-appengine/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine Java数据存储区查询-是否限制结果? - Google App Engine Java Datastore Query - Limit Results? 从iPhone更新Google App Engine中的数据存储 - Update datastore in Google App Engine from the iPhone 在DataStore Google App Engine中执行IN查询 - Execute IN query in DataStore Google App Engine 来自数据存储区Google App Engine的端点查询 - endpoint query from datastore google app engine Java Google App Engine数据存储区放置/获取 - Java Google App Engine Datastore put/get Google App Engine(Java)数据存储区检索不起作用 - Google app engine(java) datastore retrieve not working Google App Engine:java.lang.NoClassDefFoundError:com / google / appengine / api / datastore / Query $ Filter - Google App Engine: java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/Query$Filter 如何将本地Google App Engine Python数据存储区复制到本地Google App Engine Java数据存储区? - How do I copy local Google App Engine Python datastore to local Google App Engine Java datastore? Google App Engine(Java):稍后在Datastore Viewer中创建的update属性 - Google App Engine(Java): update attribute that has been created later, in Datastore Viewer Java Google App Engine数据存储区:与Python一样,在JDO查询过滤器上可以使用“ IN”运算符吗? - Java Google App Engine Datastore: 'IN' operator available on JDO query filters, as with Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM