Open GoogleCodeExporter opened 9 years ago
Please change type to enhancement and not defect.
Original comment by Jan.Most...@gmail.com
on 3 Oct 2013 at 9:55
This is the behavior of the low-level API. AFAICT, there's no configuration
option available to change that. This is really an issue to be filed in GAE's
issue tracker. If that facility becomes available, we can reopen this issue.
Objectify could manually pick values for you - but then, you could too. In
fact, that's what I do - I almost always allocate ids in the constructor, which
is far more useful than relying any any sort of low-level generation scheme.
The advantage of doing it yourself is that your entities always have ids and
thus wiring up relationships is easier.
Original comment by lhori...@gmail.com
on 3 Oct 2013 at 2:45
In retrospect, I'll leave this as an enhancement request in the backlog... It's
a legitimate feature request. Not my favorite though; I generally prefer to
follow the expected behavior of the low level api.
Original comment by lhori...@gmail.com
on 3 Oct 2013 at 3:07
This might be a stupid question, but how to you get incremental ids to pass to
the constructor without getting into a situation where two entities are given
the same id?
Are you using some sort of singleton / static counter somewhere that increments
every time you create a new instance of the object?
How do you initialize that counter and is it thread-safe to do it like this?
Original comment by Jan.Most...@gmail.com
on 3 Oct 2013 at 3:07
See ObjectifyFactory.allocateIds(), which just calls through to
DatastoreService.allocateIds().
That uses the old-style incremental id generation.
Original comment by lhori...@gmail.com
on 3 Oct 2013 at 3:11
Thanks a million!
Original comment by Jan.Most...@gmail.com
on 3 Oct 2013 at 3:12
I just tried DatastoreService.allocateIds() and it did give me incremental
ID's, but not sequential. For example, for my first 3 allocations (for a
single Kind) I got:
32001
42001
42002
I had been hoping to use incremental ID's such that I could use an array
(rather then a sparsearray) to hold the entities on my client.
Also, note this issue with the allocator:
https://code.google.com/p/googleappengine/issues/detail?id=4919
(I don't believe this was a factor in my testing.)
I find it hard to imagine that ofy could implement their own allocator without
some associated cost.
Original comment by t...@malcolmson.ca
on 1 Nov 2013 at 7:13
Yep, they're not sequential, but it's better than those massive ids it used to
generate.
Original comment by Jan.Most...@gmail.com
on 1 Nov 2013 at 7:19
I'm not getting incremental ids using ObjectifyFactory.allocateIds() ..I'm
getting random ids. Could anyone confirm?
Original comment by michaelt...@gmail.com
on 25 Mar 2014 at 11:54
Original issue reported on code.google.com by
Jan.Most...@gmail.com
on 3 Oct 2013 at 9:54