I have a Hibernate hbm.xml
mapping file which defines a large number of class mappings. Each of these needs an <id>
definition and a corresponding <generator>
definition.
In this particular application, the <generator>
definition is quite involved, including setting a number of parameters (e.g. increment size, optimizer, etc). Having to repeat this definition for every class is tedious and clutters up the mapping.
If I were using JPA annotations, I could define the ID generator at the package level. But I'm not using JPA (nor is it an option), and it seems most peculiar to be able to do something in JPA but not native hibernate.
Can I specify the generator elsewhere, and refer to it multiple times in the mapping?