objectify

Objectify NoClassDefFoundError

☆樱花仙子☆ 提交于 2020-01-01 11:58:52
问题 So I just created a new GAE project in Eclipse Indigo using the Google Eclipse Plugin, and I only have the following servlet: public class TestServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Hello, world"); Objectify obj = ObjectifyService.begin(); System.out.println(obj); } } But when I run the servlet on my browser I get: java.lang.NoClassDefFoundError: com

Querying selected fields in an entity in objectify - appengine

孤街浪徒 提交于 2019-12-31 05:15:11
问题 I am using appengine and objectify as a backend for my app. And when i query in the datastore i get a Entity object which has the data of required row. But, using objectify how will i query entities and get oly selected fileds from it? because querying the whole entity will be heavy and it needs more data bandwidth. Eg : In a entity with 4 columns, --> Id,name,description,age. I should query oly Id,name,age. I dont want description to be queried. 回答1: The GAE datastore does not work like an

Objectify queries: filter by date

会有一股神秘感。 提交于 2019-12-30 10:48:14
问题 I am using GAE and I need to write an Objectify query that asks for the elements created after September 1st. The dateCreated field is Java.util.Date and it is stored in this format 2012-11-29 16:03:59.494000. This request is NOT working: public List<MyElement> listAllFromUser(String userId) { Objectify ofy = ObjectifyService.begin(); Query<MyElement> q=ofy.query(MyElement.class).filter("dateCreated >", "2013-09-01 00:00:00"); List<MyElement> results = q.list(); return results; } 回答1: Your

How to prevent client from changing objectify @ID in Google Cloud Endpoints

痞子三分冷 提交于 2019-12-25 07:30:06
问题 I am using objectify to persist objects to Google Cloud datastore. The "primary key" is annotated with @Id. @Entity class Car { @Id Long id; ... } I generate the client endpoint (using Android Studio). I need getters and setters for all fields, including id, so that REST is able to serialize and deserialize the object. If I don't add getters and setters, then these are created by the Google endpoint builder. Normally, the client GETs an instance from datastore, changes attributes and UPDATEs

Objectify multiple filters doesn´t work with cron job

被刻印的时光 ゝ 提交于 2019-12-25 07:16:44
问题 I´m working with objectify on appengine, I tried to add a cron job to delete all temp entities which are older than an hour: Iterable<Key<Entry>> allKeys = ofy().load().type(Entry.class) .filter("temporary", true) .filter("createdAt", oneHourAgo).keys(); if(allKeys != null){ ofy().delete().keys(allKeys); } but i always get an Exception when executing the cron job on the appengine server: com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found. The suggested

Evict objects from objectify cache

五迷三道 提交于 2019-12-24 21:31:28
问题 especially Objectify team, I'm persisting my objects through this code pattern Entity filled = ofy().save().toEntity(myPojo); filled.setUnindexedProperty( "myStuff", "computedSpecialValue" ); datastore.persist(filled); Reading back my objects, I noticed they are get from cache since Objectify was not notified that it should evict the updated entity from its cache. I like the Objectify cache feature since it saves me the time to grab data from memcache and reconstuct the objects for each read,

Objectify Query a attribute from an entity

天大地大妈咪最大 提交于 2019-12-24 19:46:18
问题 Is there a possible way to query a particular attribute from an entity using Objectify, Lets say i have an Class entity with attributes {id,name,mail} ,how to filter only the mail attribute from the entity ? previously I was fetching the entire entity Objectify ofy=ObjectifyService.begin(); Query<entity> q=ofy.query(entity.class); and then retrieving the value q.getmail(); I am looking for filtering only * mail attribute from entity * in the query q ? please let me know how to do it. 回答1:

Objectify filter entities with parent key

跟風遠走 提交于 2019-12-24 14:30:45
问题 I have written a piece of code that fetches entities from google datastore by filtering the entity with the supplied parent key. When I run the code I am getting java.lang.IllegalArgumentException . I know the problem is with the way I am creating the parent key, can you please guide me how to effectively create a parent key for this use case? I am getting the below exception in Myservice.java line 8 Method threw 'java.lang.IllegalArgumentException' exception - Class hierarchy for class java

How to rename a Datastore entity field but be able to retrieve records via old and new property names?

天大地大妈咪最大 提交于 2019-12-24 09:29:02
问题 I have an entity class Foo { public String bar; } I want to rename "bar" to "somethingElse". And was planning on using Objectify's @AlsoLoad annotation to achieve that (I am already using Objectify for persistence). So something like: class Foo { @AlsoLoad("bar") public String somethingElse; } But any queries of the form: final Query<Foo> query = OfyService.ofy().load().type(Foo.class) .filter("somethingElse", "someValue"); Only retrieve entities that have been saved since the rename. Any

Achieve good paging using objectify

喜欢而已 提交于 2019-12-24 07:58:50
问题 I'm using objectify cursors to achieve basic paging, basically creating a more button.. How best do you achieve paging using objectify for building links that allow users to go forward and backwards. Something more like a page list.. 1, 2, 3, 4, more 回答1: Your best bet is probably to fetch the keys for the entire result set and stash it in a session or in javascript. Each next/previous can load the next item in your list by id. Loading by id is very cheap. You can cache the full query results