Annotation
@Table(name = “tableName”, uniqueConstraints = @UniqueConstraint(name = “uniqueName”, columnNames = “columnName”))
Example:
If you want all emails of the user table are unique, so you can create:
@Table(name = "user", uniqueConstraints = @UniqueConstraint(name = "email_user_uc" ,columnNames = "email")) public class User { @org.hibernate.validator.constraints.Email(message = "Invalid Email") @Size(max = 254, message = "It is too big") @Column @NotNull(message = "Please, set here the user email") private String email; }