Defines an index on one or more fields of a class or controls automatic index generation for columns used to complete collections mapped using a foreign key.
Defining an index on a class
The optional value attribute specifies the name of the index. The name generator for the datastore of the class provides the default name. One or more nested db-field extensions sequentially define the names for the fields in the index. The optional db-unique and db-clustered extensions default to false.
|
Copy Code |
<class name="Order">
<extension key="db-index" value="idx_cust">
<extension key="field-name" value="customer" />
</extension>
<extension key="db-index">
<extension key="field-name" value="orderDate" />
<extension key="field-name" value="orderNo" />
<extension key="db-unique" value="true" />
<extension key="db-clustered" value="false" />
</extension>
</class>
|
Controlling index generation for an one-to-many collection
Columns for a field used to complete a collection, mapped using an inverse reference field in the element-type class (refer to the inverse section) are automatically indexed. The value attribute either specifies the name of the index or "{no}", to disable the index. The name generator for the datastore of the class provides the default name. Here is an example showing how to disable the index:
|
Copy Code |
<field name="lines">
<collection element-type="OrderLine">
<extension key="inverse" value="order">
<extension key="db-index" value="{no}" />
</extension>
</collection>
</field>
|
Controlling index generation for a many-to-many collection
Columns in a link table are used to complete a collection mapped using inverse collection fields, in the element-type class (see inverse) are automatically indexed. The value attribute specifies either the name of the index or "{no}" to disable the index. The name generator for the datastore of the class provides the default name. Here is an example showing how to disable the index:
|
Copy Code |
<field name="groups">
<collection element-type="Group">
<extension key="inverse" value="users">
<extension key="db-index" value="{no}" />
</extension>
</collection>
</field>
|