Jakarta Persistence (JPA) Annotation Type

jakarta.persistence.UniqueConstraint

Implemented Interfaces:
Annotation

Specifies that a unique constraint is to be included in the generated DDL for a primary or secondary table.

Example:

 @Entity
 @Table(
     name = "EMPLOYEE",
     uniqueConstraints = @UniqueConstraint(columnNames = {"EMP_ID", "EMP_NAME"})
 )
 public class Employee { ... }
Since:
Jakarta Persistence (JPA) 1.0

Annotation Elements

String name
(Optional) The name of the constraint.

Defaults to a provider-generated name.

Default:
""
Since:
Jakarta Persistence (JPA) 2.0
String[] columnNames
(Required) The names of the column which make up the constraint.
Since:
Jakarta Persistence (JPA) 1.0
String options
(Optional) A SQL fragment appended to the generated DDL which creates this constraint.
Default:
""
Since:
Jakarta Persistence (JPA) 3.2

Additional JDK methods inherited from java.lang.annotation.Annotation

annotationType(), equals(Object), hashCode(), toString()