I am using appengine cloud endpoints and objectify. I have previously deployed these endpoints before and now I am updating them and it is not working with Objectify. I have m
At first, I did not understand the answer given by Flori, and how useful it really is. Because others may benefit, I will give a short explanation.
As explained earlier, you can use @ApiTransformer
to define a transformer for your class. This would transform an unserializable field, like those of type Key
into something else, like a Long
.
It turns out that when a class is processed by GCE, methods called get{fieldName}
and set{FieldName}
are automatically used to transform the field {fieldName}
. I have not been able to find this anywhere in Google's documentation.
Here is how I use it for the Key{Machine}
property in my Exercise
class:
public class Exercise {
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public Key machine;
// ... more properties
public Long getMachineId() {
return this.machine.getId();
}
public void setMachineId(Long machineId) {
this.machine = new Key(Machine.class, machineId);
}
// ...
}