I'm using Java Google App Engine with Objectify3.0 (so some of the kinds may look different to standard JPO/JPA).
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.
Basically, this means I want a few things:
- Retrieve all entities (around 10,000) sorted by "name" in ascending order.The 30 seconds respon开发者_如何学Gose limit will be hit if I try to get all of the entities in one go.
- Insert the order retrieved entities into another kind called: SortedByNameGame. This is the exact same kind as game (see below).
- 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.
My Game kind looks like this:
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
}
My SortedByNameGame kind looks like this:
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
}
I've considered and tried a couple of approaches (all around recursive requests) but have been unsuccessful. For example:
Cursors with tasks: I'm basically using this method: http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors
Cursors with RequestDispatcher.forward(request, response). Similar to http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors
Cursors with HttpServletResponse.sendRedirect(/pathToThisServlet). Similar to http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Cursors
Backends: http://code.google.com/appengine/docs/java/backends/overview.html. 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.
I suspect that recursive approach of requesting the same URL/Servlet aren't possible i.e. "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." (source: http://code.google.com/appengine/docs/java/urlfetch/overview.html#Responses)
My questions are
What am I doing wrong such that these recursive queue tasks aren't being created or recursive requests aren't working?
Alternatively, what other approaches exist to do what I want?
精彩评论