I'm trying to do a simple JUnit test to do a query like this:
Resource result = ofy().load().type(Resource.class).filter("raw =",
"/Bob/-/userId/-/").first().get();
if (result != null){
System.out.println("Resulting Resource raw =" + result.getRaw());
}
The query above results to null
, however when I do a query using id (which is a Long type) I get the result. When I persisted the entity I'm trying to
query I logged the @Id
and the value is 1
, so I did a query using id
to check:
Resource result =
ofy().load().type(Resource.class).filter("id =", 1).first().get();
if (result != null){
System.out.println("Resulting Resource raw =" + result.getRaw());
}
The resulting result.getRaw()
is /Bob/-/userId/-/
which is really weird, from my first query the result should have not been null
?
Check if you Have an @Index on that field, If you try to select by field that doesn't have an index you'll get null even that it is there. On several fields you'll need index on all of them of course.
*Index of more than one field will be placed in the datastore-indexes.xml https://cloud.google.com/appengine/docs/java/config/indexconfig
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With