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?
|