Top Description Methods
jakarta.persistence

public @Interface UniqueConstraint

extends Annotation
Annotations
@Target
@Retention:RUNTIME
Imports
java.lang.annotation.Target, .Retention

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 { ... }
@Entity
@Table(
    name = "EMPLOYEE",
    uniqueConstraints = @UniqueConstraint(columnNames = {"EMP_ID", "EMP_NAME"})
)
public class Employee { ... }
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public String[]
columnNames()

(Required) The names of the column which make up the constraint.

public String
name()

(Optional) The name of the constraint.

public String
options()

(Optional) A SQL fragment appended to the generated DDL which creates this constraint.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

columnNamesback to summary
public String[] columnNames()

(Required) The names of the column which make up the constraint.

nameback to summary
public String name()

(Optional) The name of the constraint.

Defaults to a provider-generated name.

Since
2.0
optionsback to summary
public String options()

(Optional) A SQL fragment appended to the generated DDL which creates this constraint.

Since
3.2