-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Implementing a db-based queue, details of id generation
PostPosted: Thu Sep 09, 2004 5:21 am 
Newbie

Joined: Thu Sep 09, 2004 5:09 am
Posts: 7
Hibernate version: 2.1
For a certain db application where we keep a queue of tasks to process in a table, we have traditionally used sql server's timestamp value as a guaranteed increasing, automatically generated binary key. (note: sql server's timestamp value is not the same as a standard SQL timestamp value) This allows us to treat the table as a queue, where we can store a timestamp value as our "current position" in the queue, and have a process wake up, and be able to step through the additions to this queue in the order they occurred, an dprocess them.

Now I am trying to get something like this to work with Hibernate, in a database-independent way. I've been looking over the different types of id generation, and some of them are sequential, but the descriptions of the algorithms are too brief (and my understanding too shallow) for me to know if any of these would be appropriate for such a situation.

The problem with using an actual "datetime" value is that the clocks of various clients could be out of sync. And I am not sure which of the hibernate generated ids are strictly increasing. The solution ideally would work with multiple clients, and as I said, be database independent.

Thanks for any advice,

Ken Larson


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 1:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
why don't you use the native generator (either sequence or identity depending the database)?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: is that always strictly increasing over time?
PostPosted: Thu Sep 09, 2004 2:01 pm 
Newbie

Joined: Thu Sep 09, 2004 5:09 am
Posts: 7
is that always strictly increasing over time?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 2:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
For identity, that would be the case I believe.

For sequences, it would depend how you defined the sequence. Sequences can actually be configured to decrement, rather than increment.


Top
 Profile  
 
 Post subject: hilo
PostPosted: Thu Sep 09, 2004 4:17 pm 
Newbie

Joined: Thu Sep 09, 2004 5:09 am
Posts: 7
thanks everyone for your help.

what exactly is the hi/lo algorithm? I've looked at the code, I've searched on the web, and I can't quite figure it out. does the hi/lo algorithm also always generate increasing values?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 11:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hi/lo can generate non incremental values (always unique however)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.