Multiple table generator in Hibernate3

Some time ago I needed a unique identifier generator that will look up a value in a simple name-value kind of database table. Project’s database layer was based on Hibernate2 and since I couldn’t find such a solution I have implemented a MultiTableGenerator which I have blogged about here.

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.

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *