title: Java Google App Engine: Retrieve all entities sorted by property and inserted for later retrieval but keeping it's insert order
body: <p>I'm using Java Google App Engine with Objectify3.0 (so some of the kinds may look different to standard JPO/JPA).</p>
  
  <p>Anyways, I want to be able to retrieve all entities sorted by a property and insert it for later retrieval so that you get the results back in the sorted order that it was inserted.</p>
  
  <p>Basically, this means I want a few things:</p>
  
  <ul>
  <li>Retrieve all entities (around 10,000)
  sorted by "name" in ascending order.The 30 seconds response limit will be hit if I try to get
  all of the entities in one go.</li>
  <li>Insert the order retrieved entities into another kind called:
  SortedByNameGame. This is the exact same kind as game (see below).</li>
  <li>Retrieve entities (with filters e.g. genre = action) from the SortedByNameGame kind but have them
  returned in the sorted ascending "name" property order in which
  entities were inserted.</li>
  </ul>
  
  <p>My Game kind looks like this:</p>
  
  <pre><code>public class Game {
      @Id private Long id; //This is my key, auto generated by objectify  
      private String name;
      private String genre; 
      private Date releasedate;
  
      //ommitting getters and setters 
  }
  </code></pre>
  
  <p>My SortedByNameGame kind looks like this:</p>
  
  <pre><code>public class SortedByNameGame {
      @Id private Long id; //This is my key, auto generated by objectify  
      private Long gameid; //This is the Long id of the Game kind shown above
      private String name;
      private String genre; 
      private Date releasedate;
  
      //ommitting getters and setters 
  }
  </code></pre>
  
  <p>I've considered and tried a couple of approaches (all around recursive requests) but have been unsuccessful. For example:</p>
  
  <ul>
  <li><p>Cursors with tasks: I'm basically using this method: <a href="http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors" rel="nofollow">http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors</a></p></li>
  <li><p>Cursors with RequestDispatcher.forward(request, response). Similar to <a href="http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors" rel="nofollow">http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors</a></p></li>
  <li><p>Cursors with HttpServletResponse.sendRedirect(/pathToThisServlet). Similar to <a href="http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors" rel="nofollow">http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors</a></p></li>
  <li><p>Backends: <a href="http://code.google.com/appengine/docs/java/backends/overview.html" rel="nofollow">http://code.google.com/appengine/docs/java/backends/overview.html</a>. Looking into this since they dont have a 30 second reponse timelimit. However, I haven't got these working yet i.e. don't know how to access them via the browser. I'm getting a 404 Error Forbidden.</p></li>
  </ul>
  
  <p>I suspect that recursive approach of requesting the same URL/Servlet aren't possible i.e. <em>"To prevent an app from causing an endless recursion of requests, a request handler is not allowed to fetch its own URL. It is still possible to cause an endless recursion with other means, so exercise caution if your app can be made to fetch requests for URLs supplied by the user."</em> (<strong>source</strong>: <a href="http://code.google.com/appengine/docs/java/urlfetch/overview.html#Responses" rel="nofollow">http://code.google.com/appengine/docs/java/urlfetch/overview.html#Responses</a>)</p>
  
  <hr>
  
  <h2>My questions are</h2>
  
  <ol>
  <li><p>What am I doing wrong such that these recursive queue tasks aren't being created or recursive requests aren't working?</p></li>
  <li><p>Alternatively, what other approaches exist to do what I want?</p></li>
  </ol>