objectify

GAE w/ Objectify - Can you query a HashMap?

[亡魂溺海] 提交于 2019-12-06 07:25:49
问题 In GAE, when using Objectify, can you query a HashMap? If so how would would you write it? ofy().load().type(MyClass.class).filter("hashMapfieldName", "keyQueryinggFor").list(); Does not seem to work where the hashMapfieldName is a HashMap<String, String> . I am looking to find entities where hashMapfieldName contains a certain key. 回答1: Just like embedded classes, Objectify converts Map<String, String> to the low-level EmbeddedEntity object, which is not indexible. However, if you @Index

Querying Geopt with Objectify

匆匆过客 提交于 2019-12-06 06:47:02
I am having the hardest time querying a GeoPt field with Objectify. I made sure there's an @Index annotation about the GeoPt field. However, the statement below doesn't seem to work ofy().load() .type(GeoStat.class) .filter("geoPt.latitude >=", neLat) .limit(10); Is querying GeoPt field possible in Objectify? stickfigure The datastore does not support querying a GeoPt in this way. If you wish to query on latitude, index it separately (possibly writing to a private field in an @OnSave method). However, if you're trying to perform a geospatial query (ie, contained in a rectangle), note that you

Service error in memcache with Java Google App Engine Standard at random time periods

倖福魔咒の 提交于 2019-12-06 06:22:21
问题 In the past month, our Java Google App Engine Standard Web App started getting strange errors at seemingly random times (see stack trace below). Around this time we made the following changes: Switch from Java7 runtime to Java8/Jetty9 runtime (which allowed us more flexibility in linking to a 3rd party payments library). Switch to deploying with the Google Cloud SDK, instead of the separate Google App Engine SDK. Yesterday we experienced 3 periods with errors. One of these occurred from

Case insensitive filter query with Objectify + google appengine

杀马特。学长 韩版系。学妹 提交于 2019-12-06 04:16:21
问题 Is there an easy way to do a case insensitive filter query with Objectify + google appengine (Java)? Essentially this is what I am trying to do except that I need the filter on email to be case insensitive. Objectify objectifyService = ObjectifyService.begin(); objectifyService.query(AppUser.class).filter("email", email).get(); 回答1: You need to store your email address in a normalized (lowercase or uppercase, for instance) form in the datastore, and query on that. If you also need the

How do you implement cascading delete in Objectify?

我们两清 提交于 2019-12-06 01:29:54
问题 I have the following heriacy. GrandParent --> Parent --> Child Parent and Child use @Parent Ref<GrandParent> and @Parent Ref<Parent> to create there parent relationship. I am trying to come of with a good way to do a cascading delete for GrandParent . I of course I could load all the children, generate keys from them and delete by key. This seems terribly inefficient. Is there something where I could query by parent and turn the query results into a list of keys without having to do the full

Getting Entity Key with Objectify 4

无人久伴 提交于 2019-12-05 19:52:55
I need to do getKey() with this kind of Entity: @Entity public class Value { @Id private long id; private byte[] value; com.googlecode.objectify.Key<Value> getKey() { return com.googlecode.objectify.Key.create(Value.class, id); // When executed this line throws NullPointerException } // Code omitted } However the pattern I used before with version 3 seems to be not applicable anymore. The @Transient is replaced by @Ignore but when I annotate my getKey() function with @Ignore I get this error: The annotation `@Ignore` is disallowed for this location So I just commented it out. And see if it

Datastore Query returns null

北慕城南 提交于 2019-12-05 19:26:37
I am trying to retrieve a sorted list of the players scores from a datastore Entity of type"User" After executing: List<User> entities = ofy().load().type(User.class).order("-score").list(); Knowing that I indexed the "score" attribute. Here is the "User.class" @Id String userName; String password; @Index int score; The entities seem to be null and i can't get the entities details.What am I missing??? I am still working on that I managed to modify the method to: @Override public User display(){ List<User> list = ofy().load().type(User.class).order("-score").limit(5).list(); User u= list.get

Efficient way to query all records where a field is not null in objectify

时光总嘲笑我的痴心妄想 提交于 2019-12-05 16:23:09
I want to query an indexed field efficiently to retrieve all records where the indexed field is not null (present in the index). The field to be queried contains a Ref<T> to another entity, in case this is relevant. What I could do is an inequality search, like .filter/.filterKey("fieldname >=", "a") , where a is the smallest ASCII that I want to grab. But is this efficient? Or can I do an equality search somehow, which returns all records that are present in the index? -- This is how my data looks like: I want to filter all records where the "overlay" column has a key, and omit those where

Objectify paging [closed]

眉间皱痕 提交于 2019-12-05 09:35:23
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Can you find a good tutorial or documentation about achieving a good pagination in a Google App Engine Objectify world? I found some posts: http://groups.google.com/group/objectify-appengine/browse_thread/thread/b640b5d377b620b4 But nothing seems to help me. Is there some sort of LIMIT query? The post you linked to describes the correct way to do pagination: Using cursors. You can fetch using offsets and limits,

Why do I get Only ancestor queries are allowed inside transactions error

☆樱花仙子☆ 提交于 2019-12-05 09:19:25
boolean r = ofy().transact(new Work<Boolean>() { @Override public Boolean run() { Visit visit = ofy().load().type(Visit.class) .filter(Visit.USER_ID, userID) .filter(Visit.VENUE_ID, venueID).first().get(); if (visit == null) return false; visit.setLastRequestDate(new Date(timestamp)); ofy().save().entity(visit).now(); return true; } }); and I get java.lang.IllegalArgumentException: Only ancestor queries are allowed inside transactions. for the line with the get() call. why? I'm only querying Visit entity in this transaction. I'm doing this in a transaction, because I want all this to be