We have multiple J2EE instances running in a clustered environment with Hibernate 4.1.5.SP1. We need to be capable of assigning a unique ID to specific records during the initial INSERT to the database based upon specific business needs. For some domain objects, the unique ID increments based on whether it's within the same region, customer, division, or by unique facility. The biggest issue is how to control this across multiple JVMs within a cluster to insure that two or more JVMs don't happen to assign an INSERT with the same number.
I'd rather not consider applying a table lock in order to insert/generate the ID for each specific JVM instance. Note that the use of the database-specific SEQUENCE or IDENTITY concept isn't ideal for these generated values because the need to maintain various number ranges for the same column depending on other values in the database columns.
Ideas?
|