Google states that the the Google App Engine Datastore support the following types.
Java Properties and value types
Among these is com.google.appengine.api.users.User.
However when I try to persist my entity it is throwing the following excpetion.
[INFO] java.lang.NullPointerException
[INFO] at com.google.storage.onestore.v3.OnestoreEntity$PropertyValue$UserValue.setAuthDomain(OnestoreEntity.java:1145)
[INFO] at com.google.appengine.api.datastore.DataTypeTranslator$UserType.toV3Value(DataTypeTranslator.java:994)
[INFO] at com.google.appengine.api.datastore.DataTypeTranslator.addPropertyToPb(DataTypeTranslator.java:165)
[INFO] at com.google.appengine.api.datastore.DataTypeTranslator.addPropertiesToPb(DataTypeTranslator.java:138)
[INFO] at com.google.appengine.api.datastore.EntityTranslator.convertToPb(EntityTranslator.java:61)
[INFO] at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$4.toPb(AsyncDatastoreServiceImpl.java:203)
[INFO] at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$4.toPb(AsyncDatastoreServiceImpl.java:180)
[INFO] at com.google.appengine.api.datastore.Batcher$BatchIterator.<init>(Batcher.java:177)
...
I tried registering it with Objectify using my own service, but it'll just say entity not found, not surprising as it is not annotated with Objectify's @Entity.
How do you persist the Google User type with Objectify?
** UPDATE **
I seem to be having problems with other Google Types as well.
e.g.
com.google.appengine.api.datastore.Email
Entity Class
package com.propertywrassler.webservice.maintenance;
import com.google.api.server.spi.response.BadRequestException;
import com.google.appengine.api.users.User;
import com.googlecode.objectify.annotation.Entity;
import com.propertywrassler.webservice.util.ErrorMessage;
import com.propertywrassler.webservice.util.PropertyWrasslerChildEntity;
import lombok.Getter;
import lombok.Setter;
import org.joda.time.DateTime;
@Entity
public class Comment extends MyChildEntity<ThingYouComment, Comment> {
@Getter @Setter private User author;
@Getter @Setter private DateTime timeStamp = new DateTime();
@Getter @Setter private String text;
@Override
public void validate() throws BadRequestException {
super.validate();
if (author == null) {
throw new BadRequestException(ErrorMessage.requiredField("author"));
}
if (text == null) {
throw new BadRequestException(ErrorMessage.requiredField("text"));
}
}
}
In Service I persist like so. Everything works fine till service. Endpoints serialized the object correctly and all. User object is perfect. Problem is at the following line.
ofy().save().entity(comment).now();