I have an app engine application and I want to run a query that sorts the result based on a expression involving two properties. Best way I thought of doing it so far is to create a computed/calculated property that stores the result of that expression. Although I saw that GAE in Python offers a ComputedProperty, which seems to be exactly what I'm looking for, I couldn't find an equivalent in Java.
I'm currently using Objectify too, if that helps.
Any ideas?
Compute your value in an @OnSave method:
This is what NDB's ComputedProperty actually does. Java doesn't really have a way of matching that syntax, and I'm not sure NDB's approach is any more elegant. Just leave off the setter method for
computed
.You can create an index which involves multiple properties. Something like this:
Read more about it here: https://cloud.google.com/appengine/docs/java/config/indexconfig