Version: 3.0 (31.03.2005)
Use Case: My object model is broad, with a limited set of common fields, so I want to use table-per-concrete-class rather than table-per-class-hierarchy. However, I have queries on some of those common fields, so want them indexed in the database for all tables.
Mapping File:
Code:
<hibernate-mapping>
<class name="dao.BaseClass">
<id name="id" unsaved-value="null" column="ID">
<generator class="native"/>
</id>
<property name="strval" type="string" length="16">
<column name="STR_VAL" index="idx_baseclass_strval"/>
</property>
<union-subclass name="dao.ChildClass">
<property name="datval" type="timestamp"/>
<union-subclass name="dao.GrandchildClass">
<property name="zippy" type="string" length="16"/>
</union-subclass>
</union-subclass>
</class>
</hibernate-mapping>
The generated SQL creates an index on BaseClass (STR_VAL), but not on ChildClass(STR_VAL) or GrandchildClass(STR_VAL).
Examining the SQL generation code, this appears to be intentional: DenormalizedTable does not override getIndexIterator() and Index.sqlCreateString() does not take a parameter for indexed table.
My question: is this an oversight that will be corrected in a future release, or is it intentional? I realize that there are a lot of special cases regarding index naming (eg, Oracle scopes names by schema, while Sybase/SQL-Server scopes them by table). For our case, I plan to enable index propagation using Oracle-style conventions, but this is a bit of a hack.