I've been tasked with reverse engineering Hibernate mappings from a large, legacy, sql server database. The database makes extensive use of check constraints (several per table) and indexes, and while I would argue that these are DBA concerns, we're required to preserve them in the Hibernate mappings.
Using Hibernate Tools for Eclipse, I can successfully reverse engineer our tables into .hbm.xml files; however, none of the check constraints or indexes are present. I know that it's possible to manually add both check constraints and indexes directly to the mapping, e.g.:
Code:
<class name="package.Tablename"
table="TABLENAME"
schema="dbo"
catalog="MyDB"
check="START_DATE < END_DATE"> <!-- here -->
...
<property name="endDate" type="timestamp" index="IDX_END_DATE"> <!-- here -->
<column name="END_DATE" />
</property>
...
</class>
We have hundreds of tables and thousands of indexes/check constraints, so adding these by hand to the reverse engineered mappings isn't really feasible.
Another Hibernate user mentioned using templates to do this, but it's my understanding that templates are only useful for modifying the format of the generated artifacts or substituting values for known properties. Hibernate seems completely unaware of the check constraints and indexes when it looks at the table, so I don't understand how templates would help.
Is it possible to reverse engineer indexes/check constraints with Hibernate Tools?