title: Google App Engine - How do you persist Google User type with Objectify?
body: <p>Google states that the the Google App Engine Datastore support the following types.</p>
  
  <p><a href="https://developers.google.com/appengine/docs/java/datastore/entities#Java_Properties_and_value_types" rel="nofollow"><strong>Java Properties and value types</strong></a></p>
  
  <p>Among these is <code>com.google.appengine.api.users.User</code>.</p>
  
  <p>However when I try to persist my entity it is throwing the following excpetion. </p>
  
  <pre><code>[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.&lt;init&gt;(Batcher.java:177)
  ...
  </code></pre>
  
  <p>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.</p>
  
  <p><strong>How do you persist the Google User type with Objectify?</strong></p>
  
  <p>** UPDATE **</p>
  
  <p>I seem to be having problems with other Google Types as well. </p>
  
  <blockquote>
    <p>e.g. <code>com.google.appengine.api.datastore.Email</code></p>
  </blockquote>
  
  <p><strong>Entity Class</strong></p>
  
  <pre><code>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&lt;ThingYouComment, Comment&gt; {
  
      @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"));
          }
      }
  
  }
  </code></pre>
  
  <p><strong>In Service I persist like so.</strong> Everything works fine till service. Endpoints serialized the object correctly and all. User object is perfect. Problem is at the following line.</p>
  
  <pre><code>ofy().save().entity(comment).now();
  </code></pre>