I am trying to load an entity by id to check if it exists. If I call as below it returns null:
String idS = lat+lon+lang;
GeoVars response = ofy().load().type(GeoVars.class).id(idS).now(); //Always returns null
If I turn off the cache it returns the entitiy:
GeoVars response = ofy().cache(false).load().type(GeoVars.class).id(idS).now(); //Returns OK
And here is the GeoVars class:
@Entity
@Cache
public class GeoVars {
@Id String id;
String summary;
String something;
String another;
String blabla;
String lang;
int day;
I understand that memcache is "best effort" basis but even it is not cached, it should take the entity from datastore automatically? Why does load return null?
EDIT:
When I try with safe, also returns null.
try {
response = ofy().load().type(GeoVars.class).id(idS).safe();
} catch (com.googlecode.objectify.NotFoundException e) {
e.printStackTrace();
response = createResponse(idS, lat, lon, lang, dayofweek);
ofy().save().entity(response);
}
now()
tosafe()
? - tx802catch(NotFoundException)
block. - tx802