I decided to make use of a Hibernate id generator which meet the following requirements: - safe id generation when the domain is accessed from different applications(different JVMs) - make use of id intervals (do not query the database every time a new ID is needed)
After some investigations I choose one of 2 hibernate enhanced identifier generators, it's the
org.hibernate.id.enhanced.TableGenerator
The problem is that this algorithm keep in database not the next value available but the end of the next available interval, so, let's say I have an id generator with increment_size 10, when i make a request for an id I receive the interval 1 - 10, but in the database is now stored not the value 11, but 21. With this behavior I have to keep the increment_size the same along all classes that map to a specific table. Why it have this behavior ? Is there any way to fix this ?
|