I\'ve generally implemented sequence number generation using database sequences in the past.
e.g. Using Postgres SERIAL type http://www.neilconway.o
Now there are more options.
Though this question is "old", I got here, so I think it might be useful to leave the options I know of (so far):
Cheers