1 /*
2 * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0 which is available at
6 * http://www.eclipse.org/legal/epl-2.0,
7 * or the Eclipse Distribution License v. 1.0 which is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 *
10 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11 */
12
13 // Contributors:
14 // Linda DeMichiel - 2.1
15
16 package javax.persistence;
17
18 import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.Target;
21
22 /**
23 * Used in schema generation to specify creation of an index.
24 * <p>
25 * Note that it is not necessary to specify an index for a primary key,
26 * as the primary key index will be created automatically.
27 *
28 * <p>
29 * The syntax of the <code>columnList</code> element is a
30 * <code>column_list</code>, as follows:
31 *
32 * <pre>
33 * column::= index_column [,index_column]*
34 * index_column::= column_name [ASC | DESC]
35 * </pre>
36 *
37 * <p> If <code>ASC</code> or <code>DESC</code> is not specified,
38 * <code>ASC</code> (ascending order) is assumed.
39 *
40 * @see Table
41 * @see SecondaryTable
42 * @see CollectionTable
43 * @see JoinTable
44 * @see TableGenerator
45 *
46 * @since 2.1
47 *
48 */
49 @Target({})
50 @Retention(RUNTIME)
51 public @interface Index {
52
53 /**
54 * (Optional) The name of the index; defaults to a provider-generated name.
55 */
56 String name() default "";
57
58 /**
59 * (Required) The names of the columns to be included in the index,
60 * in order.
61 */
62 String columnList();
63
64 /**
65 * (Optional) Whether the index is unique.
66 */
67 boolean unique() default false;
68
69 }
70