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"
m |
m |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | ---- | ||
+ | |||
+ | |||
+ | '''[[Image:Elug_draft_icon.png|Warning]] This page is now obsolete. ''' | ||
+ | |||
+ | For current information, please see "@Index" in the ''Java Persistence API (JPA) Extensions Reference for EclipseLink'': http://eclipse.org/eclipselink/documentation/latest/jpa/extensions/a_index.htm | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
{{EclipseLink_UserGuide | {{EclipseLink_UserGuide | ||
|info=y | |info=y | ||
Line 7: | Line 18: | ||
|apis= | |apis= | ||
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/Index.html @Index] | * [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/Index.html @Index] | ||
+ | |nativeapi=y | ||
+ | |nativeapis= | ||
* [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] | ||
}} | }} | ||
Line 89: | Line 102: | ||
{{EclipseLink_JPA | {{EclipseLink_JPA | ||
− | |previous =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation| | + | |previous =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation/CascadeOnDelete|@CascadeOnDelete]] |
|up =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation|Schema Generation]] | |up =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation|Schema Generation]] | ||
− | |next =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation/ | + | |next =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation/Appending_strings_to_CREATE_TABLE_statements|Appending Strings to CREATE TABLE Statements]] |
|version=2.2.0 DRAFT}} | |version=2.2.0 DRAFT}} |
Latest revision as of 07:28, 17 April 2013
For current information, please see "@Index" in the Java Persistence API (JPA) Extensions Reference for EclipseLink: http://eclipse.org/eclipselink/documentation/latest/jpa/extensions/a_index.htm
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
Native API
@Index
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 eclipselink-orm.xml descriptor 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.
Index creation is database specific. Some databases may not support indexes. Most databases auto-index primary key and foriegn key columns. Some databases support advanced index DDL options. To create more advanced index DDL, a DDL script or native query can be used.
Attribute | Description | Default | Required? |
---|---|---|---|
catalog | The catalog of the INDEX. | Default catalog | 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. | <table>_<column>_INDEX (but a name should be provided) | No |
schema | The schema of the INDEX. | Default schema | 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 |
This example defines three indexes, one on first name, one on last name, and a multiple column index on first name and last name.
@Entity @Index(name="EMP_NAME_INDEX", columns={"F_NAME","L_NAME"}) public class Employee{ @Id private long id; @Index @Column(name="F_NAME") private String firstName; @Index @Column(name="L_NAME") private String lastName; ... }
You can also create an index in the eclipselink-orm.xml descriptor using <index>, as shown in the following example. Define columns using the <column> subelement. All the attributes supported in the @Index annotation are also supported in the <index> element.
<index name="EMP_NAME_INDEX" table="EMPLOYEE" unique="true"> <column>F_NAME</column> <column>L_NAME</column> </index>