Unfortunately there's nothing you can do right now to get JDO to give you a monotonically increasing sequence. The App Engine's JDO implementation is based on the features of the datastore, and since the datastore does not support monotonically increasing sequences the JDO implementation does not either. You could implement this yourself on top of the datastore and then write your own JDO sequence provider, but you're going to end up doing an extra round-trip to the datastore for every write that needs a sequence value. This performance/cpu hit may be acceptable for your app or it may not. My advice would be to try to make do without a monotonically increasing sequence, but if you need it you need it.
Max On Mon, Dec 21, 2009 at 11:26 PM, Philip Tucker <[email protected]> wrote: > Hmm, I thought I'd read that in the DataNucleus documentation, but I > can't find any clear definition of it. I must have just assumed > sequences were sequential. > > Borrowing from your example here (http://code.google.com/p/datanucleus- > appengine/source/browse/trunk/tests/org/datanucleus/test/<http://code.google.com/p/datanucleus-%0Aappengine/source/browse/trunk/tests/org/datanucleus/test/> > SequenceExamplesJDO.java), it seems if I specify a named sequence and > set SequenceStrategy.CONTIGUOUS (NONCONTIGUOUS might work too, I'm > guessing !TRANSACTIONAL is the key) that I get a monotonically > increasing sequence. Does that seem right? > > Thanks for the input, > Philip > > On Dec 21, 2:46 pm, "Max Ross (Google)" > <[email protected]<maxr%[email protected]> > > > wrote: > > Where are you reading the definition of the contract? > > > > > > > > On Mon, Dec 21, 2009 at 2:41 PM, Philip Tucker <[email protected]> > wrote: > > > Thanks! > > > > > Unless I'm misreading the documentation for SEQUENCE, that breaks the > > > contract of the JDP annotation API, doesn't it? > > > > > Is there a way to annotate a field as a true sequence, or do I need to > > > create my own sequence and assign the value myself? > > > > > On Dec 21, 9:29 am, "Max Ross (Google)" > > > <[email protected]<maxr%[email protected]> > <maxr%[email protected] <maxr%[email protected]>> > > > > > wrote: > > > > Hi Philip, > > > > > > IdGeneratorStrategy.SEQUENCE support is implemented on top of > > > > DatastoreService.allocateIds(), which is itself the mechanism that > the > > > > datastore uses internally to assign ids. So, all properties of > datastore > > > id > > > > allocation apply to SEQUENCE. There is a lot of good information > about > > > > these properties in this thread: > > >http://groups.google.com/group/google-appengine/browse_thread/thread/. > .. > > > > > > But in short, sequences are guaranteed to be unique but not > monotically > > > > increasing. > > > > > > Hope this helps, > > > > Max > > > > > > On Mon, Dec 21, 2009 at 12:04 AM, Philip Tucker <[email protected]> > > > wrote: > > > > > I'm using IdGeneratorStrategy.SEQUENCE for the primary key of a > table, > > > > > but it appears AppEngine bounces between 2 different sequence > > > > > generators as I create new entries. IDs are unique, but not > > > > > monotonically increasing. It's possible I've coded something wrong, > > > > > but I'm oretty sure this is a bug. > > > > > > > -- > > > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "Google App Engine for Java" group. > > > > > To post to this group, send email to > > > > > [email protected]. > > > > > To unsubscribe from this group, send email to > > > > > [email protected]<google-appengine-java%[email protected]><google-appengine-java%2B > [email protected]><google-appengine-java%2B > > > [email protected]> > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/google-appengine-java?hl=en. > > > > > -- > > > > > You received this message because you are subscribed to the Google > Groups > > > "Google App Engine for Java" group. > > > To post to this group, send email to > > > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<google-appengine-java%[email protected]><google-appengine-java%2B > [email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-appengine-java?hl=en. > > -- > > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
