title: Objectify List<Ref<T>> not serialized by Google App Engine endpoints
body: <p>Hi have two related Entities: Customers and Cars. Each Customer can own several Cars</p>
  
  <p>This is a summarized view of the entities:</p>
  
  <pre><code>public class Customer 
  {
      //Inner classes for partial loads
      public static class NoCars{}
  
      @Id protected String id;
      private String fullName;
      @Load(unless=NoCars.class) private List&lt;Ref&lt;Car&gt;&gt; cars;
  }
  
  public class Car
  {
      @Id private Long id;
      private String makeAndModel;
      private String plateNumber;
  }
  </code></pre>
  
  <p>And this is a method that retrieves a Customer from datastore <strong>and all the Cars</strong> he owns:</p>
  
  <pre><code>public Customer getCustomer(@Named("id") String customerId)
  {
      Customer customer =  ofy().load().type(Customer.class).id(customerId).now();
      if (customer==null)
          throw new NotFoundException("customer not found");
      else
          return customer;
  }
  </code></pre>
  
  <p>endpoints.sh cannot implement this, as the type <strong><code>List &lt;Ref&lt;Car&gt;&gt;</code></strong> included in the return type <em>Customer</em> is not supported, but I found this funny workaround:</p>
  
  <p>I created the class <em>CustomerPOJO</em></p>
  
  <pre><code>public class CustomerPOJO
  {
      private String fullName;
  }
  </code></pre>
  
  <p>and modified the class <em><code>Customer</code></em> to extend from it</p>
  
  <pre><code>public class Customer extends CustomerPOJO
  {
      //Inner classes for partial loads
      public static class NoCars{}
  
      @Id protected String id;
      @Load(unless=NoCars.class) private List&lt;Ref&lt;Car&gt;&gt; cars = new ArrayList&lt;&gt;();
  }
  </code></pre>
  
  <p>and the getter method to be:</p>
  
  <pre><code>public CustomerPOJO getCustomer(@Named("id") String customerId)
  {
      Customer customer =  ofy().load().type(Customer.class).id(customerId).now();
      if (customer==null)
          throw new NotFoundException("customer not found");
      else
          return customer;
  }
  </code></pre>
  
  <p>Note that the method declares <em><code>CustomerPOJO</code></em> as return type, but it actually returns a "full" <em><code>Customer</code></em>!!!</p>
  
  <p><strong>This works in AppEngine 1.8.0 + Objectify 4.0 RC2</strong>. It gets the customer data and all the cars he owns with their properties (<em><code>makeAndModel</code></em> and <em><code>plateNumber</code></em>) in a single call.</p>
  
  <p>The issue came after upgrading to 1.8.9. endpoints.sh still works, as the return type is fully compatible, but i get an exception at runtime, when parsing the Customer objecto to JSON.</p>
  
  <blockquote>
    <p>java.io.IOException:
    com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException:
    Direct self-reference leading to cycle (through reference chain:
    entity.Customer["cars"]->java.util.ArrayList[0]->com.googlecode.objectify.impl.ref.LiveRef["key"]->com.googlecode.objectify.Key["root"])</p>
  </blockquote>
  
  <p><strong>Any other workaround that works in 1.8.9? Is @ApiTransformer the only choice?</strong></p>