Multiple table generator in Hibernate3
by Dejan Bosanac
The project was finished and I moved on. Since then, many people reported that my solution was not compatible with Hibernate3 but unfortunately I never found time to fix it. Luckily, I was recently reported that Hibernate team introduced this functionality in Hibernate3. The class is called
org.hibernate.id.MultipleHiLoPerTableGenerator. As I can see, it is not documented in the latest version of the reference documentation yet, but you can find a description in a JavaDoc documentation.
The configuration syntax of these two solutions looks similar (parameter names have been changed), which makes it even easier to port functionality if you are migrating to Hibernate3. It is good to see useful stuff becoming a standard part of the library.
This generator is really useful actually.
Having all id labels in a single table improves clarity and maintenance.
However beware, this generator has a jdbc connection leakage, what could very annoying: