I am using Google App engine1.9.3, Eclipse, Objectify5.03. My Class is as follows:
import com.googlecode.objectify.Ref;
import com.googlecode.objectify.annot
Google Cloud Endpoints is unable to serialise the Ref
object because it is an arbitrary object defined by objectify
, therefore not supported as the error indicates.
This is known limitation with Cloud Endpoints in that it does not allow custom objects to be used. There is a whole discussion thread on this point in particular if you're interested: Cloud endpoints .api generation exception when using objectify (4.0b1) parameterized key
You will have to annotate your methods with @ApiResourceProperty
and set its ignored attribute to true
as illustrated in the code below:
import com.googlecode.objectify.Ref;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Load;
import com.google.api.server.spi.config.AnnotationBoolean;
import com.google.api.server.spi.config.ApiResourceProperty;
@Entity
public class User
{
@Id private Long userId;
private String userName;
@Load private Ref userDetails;
@Load private Ref userPassword;
//getters & setters
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public UserDetail getUserDetails(){
}
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public UserPassword getUserPassword(){
}
}
If you still want to use the data held in those objects then consider adding some fields to your class to hold the data and initialise them after your User
class has finished loading like so:
@Ignore String firstName;
@OnLoad
void trackUserDetails()
{
this.firstName = getUserDetails().getFirstName();
// add more code here to set other fields, you get the gist
}
But in my opinion a better approach would be to reconsider the design of your class, or rather rethink what you're trying to do.