Excellent! Exactly what I was looking for.. Syntax isn't all that
important since I'm only doing it in a few places. However, now that
I realize an ID can be generated without a put(), I'll probably end up
using it more frequently. Instead of returning a long, I would almost
prefer some sort of pre-put() that fills that field directly. E.g.
ResponseData rd = new ResponseData(...);
ofy.generateId(rd); // Could return the id that was generated
// Do stuff with ID
ofy.put(rd);
Anyways, thanks again! Most helpful list ever.
Jake
On May 25, 12:38 pm, Jeff Schnitzer <j...@infohazard.org> wrote:
> You can explicitly allocate the two ids in advance:
>
> long responseId =
> ofy.getDatastoreService().allocateIds(fact.getKind(Response.class),
> 1).getStart().getId();
> long responseDataId =
> ofy.getDatastoreService().allocateIds(fact.getKind(ResponseData.class),
> 1).getStart().getId();
>
> Not the most elegant syntax, but nobody has asked for an
> ObjectifyFactory method to allocate ids before. If you'd like, we can
> add one that looks like this:
>
> long responseId = fact.allocateIds(Response.class, 1).getStart().getId();
>
> Jeff
>
Jeff
Objectify get() methods always try to return results in the same order
the keys were specified.
Jeff