Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/JPA/Indexes

< EclipseLink‎ | Examples‎ | JPA
Revision as of 12:24, 24 January 2011 by James.sutherland.oracle.com (Talk | contribs) (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...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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