I use the "increment" hibernation generator to generate auto increment identifiers. This worked fine until I had to add another application that also uses the increment generator to generate new identifiers. I realized that there is a catch with the increment generator:
"generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. Do not use in a cluster."
Is there any way to handle this using sleep mode? Or will I have to write additional code to lock the table, check db for max Id (and then increase it), and finally release the lock? Using a single sleep configuration is not an option. Also, I cannot add the auto_increment parameter to the db table, because we have more than one key in the table.
Any suggestions are welcome, I assume this is a common problem.
source
share