Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/Indexes"

(New page: Indexes EclipseLink (as of 2.2) provides a way to have a database INDEX generated when EclipseLink is used to generate the database. An [http://en.wik...)
(No difference)

Revision as of 12:24, 24 January 2011


EclipseLink (as of 2.2) provides a way to have a database INDEX generated when EclipseLink is used to generate the database. An index is used in a database to optimize queries that use that column to provide optimal look-up and avoid table scans. Different databases have different levels of index support, EclipseLink supports the creation of basic indexes on databases that support them. EclipseLink supports index creation using its @Index annotation or <index> xml element. The @Index has a name and a set of columns.

Example Index

The firstName and lastName are indexed.

@Entity
@Index(name="EMP_NAME_INDEX", columns={@Column(name="F_NAME"),@Column(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;
    ...
}

This produces the SQL,

CREATE INDEX 
</sql>

Back to the top