-->
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.  [ 1 post ] 
Author Message
 Post subject: Using Sequences for non-IDs
PostPosted: Fri Mar 23, 2007 4:05 pm 
Newbie

Joined: Fri Mar 23, 2007 3:52 pm
Posts: 2
I have a requirement that I'm having some trouble implementing.

Basically I have an object Foo that in addition to the id has a second value, number.

While every Foo has an id only some Foos have a number. The number must be unique, and in consecutive order, the order isn't the order in which the Foos are saved to the database but the order in which the number is assigned to the Foo.

The ugly solution is to create a table, FooNumberGenerator, whose sole purpose is to generate new IDs by creating and saving a new one whenever we need a number. However this isn't ideal for obvious reasons.

Another solution is to execute the sequence SQL directly but I want to avoid this for portability reasons.

I was hoping to use something like SequenceGenerator but it looks like SequenceGenerator only works for certain databases (calling configure with MySQL5Dialect results in "Dialect does not support sequences").

Is there a clean way to accomplish this or do I need the FooNumberGenerator?


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

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.