I am using hibernate's "increment" generator to generate my auto increment Id's. This was working fine until I had to add another application which also uses the "increment" generator to generate new id's. I realised 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 deal with this using hibernate? Or will I have to write additional code to lock the table, check the db for max Id (and then increment it) and finally release the lock? Using one hibernate configuration is not an option. Also I can not add the auto_increment option to the db table because we have more than one key on the table.
Any suggestions are welcome, I am guessing this is a common problem.