1 /*
2 * Copyright (c) 2008, 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 // Linda DeMichiel - 2.0
16
17 package javax.persistence;
18
19 import java.lang.annotation.Target;
20 import java.lang.annotation.Retention;
21 import static java.lang.annotation.RetentionPolicy.RUNTIME;
22
23 /**
24 * Specifies that a unique constraint is to be included in
25 * the generated DDL for a primary or secondary table.
26 *
27 * <pre>
28 * Example:
29 * @Entity
30 * @Table(
31 * name="EMPLOYEE",
32 * uniqueConstraints=
33 * @UniqueConstraint(columnNames={"EMP_ID", "EMP_NAME"})
34 * )
35 * public class Employee { ... }
36 * </pre>
37 *
38 * @since 1.0
39 */
40 @Target({})
41 @Retention(RUNTIME)
42 public @interface UniqueConstraint {
43
44 /** (Optional) Constraint name. A provider-chosen name will be chosen
45 * if a name is not specified.
46 *
47 * @since 2.0
48 */
49 String name() default "";
50
51 /** (Required) An array of the column names that make up the constraint. */
52 String[] columnNames();
53 }
54