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
Compute your value in an @OnSave method:
@Entity
public class YourEntity {
@Id Long id;
String foo;
String bar;
@Index String computed;
@OnSave void computeComputed() {
computed = // synthesize from foo and bar
}
}
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
.