Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/Schema Generation/Index"
< EclipseLink | UserGuide | JPA | Advanced JPA Development | Schema Generation
m |
m |
||
Line 9: | Line 9: | ||
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/tools/schemaframework/IndexDefinition.html IndexDefinition] | * [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/tools/schemaframework/IndexDefinition.html IndexDefinition] | ||
}} | }} | ||
− | |||
− | |||
− | |||
=@Index Annotation and <index> XML= | =@Index Annotation and <index> XML= | ||
− | + | --THIS PAGE IS IN PROGRESS. Please see Discussion page.-- | |
An index is a database structure defined for a table, to improve query and look-up performance for a set of columns. | An index is a database structure defined for a table, to improve query and look-up performance for a set of columns. | ||
− | Use the @Index annotation in code or the <index> element in the orm.xml desciptor to create an index on a table. | + | Use the <tt>@Index</tt> annotation in code or the <tt><index></tt> element in the <tt>orm.xml</tt> desciptor to create an index on a table. |
An index can be defined on an Entity or on an attribute. For the Entity it must define a set of columns to index. | An index can be defined on an Entity or on an attribute. For the Entity it must define a set of columns to index. | ||
+ | |||
+ | <source lang="java"> | ||
+ | // Need code sample. | ||
+ | </source> | ||
{{EclipseLink_AttributeTable | {{EclipseLink_AttributeTable | ||
Line 57: | Line 58: | ||
<tr> | <tr> | ||
<td>'''<tt>unique</tt>'''</td> | <td>'''<tt>unique</tt>'''</td> | ||
− | <td> | + | <td>Specify whether the index is unique or non-unique.</td> |
<td><tt>false</tt></td> | <td><tt>false</tt></td> | ||
<td>No</td> | <td>No</td> | ||
Line 63: | Line 64: | ||
}} | }} | ||
− | + | <!-- | |
− | + | <tt>@Index</tt> creates an <tt>IndexDefinition</tt> and stores it on the descriptor's <tt>DatabaseTable</tt>. During default schema generation the <tt>DefaultSchemaGenerator</tt> adds the <tt>IndexDefinition</tt> to the <tt>TableDefinition</tt> to be created. The <tt>IndexDefinition</tt> is used to create indexes for primary key and unique constraints. Support for indexes is defined in the platform. By default a platform is assumed to support indexes. MySQL requires special drop syntax to include the table name in the drop statement. --> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
= Configuration File = | = Configuration File = |
Revision as of 12:04, 31 January 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
@Index Annotation and <index> XML
--THIS PAGE IS IN PROGRESS. Please see Discussion page.--
An index is a database structure defined for a table, to improve query and look-up performance for a set of columns. Use the @Index annotation in code or the <index> element in the orm.xml desciptor to create an index on a table.
An index can be defined on an Entity or on an attribute. For the Entity it must define a set of columns to index.
// Need code sample.
Attribute | Description | Default | Required? |
---|---|---|---|
catalog | The catalog of the INDEX. | ? | No |
columnNames | Specify the set of columns to define the index on. | For an Entity , the table. For an attribute, the table and column. | Not required when annotated on a field or method. |
name | The name of the INDEX. | _<column>_INDEX (but a name should be provided) | No |
schema | The schema of the INDEX. | ? | No |
table | The table to define the index on, defaults to entities primary table. | The entity's primary table. | No |
unique | Specify whether the index is unique or non-unique. | false | No |
Configuration File
Create an index in orm.xml using <index>, as follows:
<index name="EMP_NAME_INDEX" table="EMPLOYEE" unique="true"> <column>F_NAME</column> <column>L_NAME</column> </index>