Package org.hibernate.annotations
Annotation Type Check
@Target({TYPE,METHOD,FIELD})@Retention(RUNTIME)@Repeatable(Checks.class)public @interfaceCheck
Specifies acheckconstraint to be included in the generated DDL.- When a basic-typed field or property is annotated, the check constraint is added to thecolumn definition.
- When a
ManyToOneassociation is annotated, the check constraint is added to thejoin column definition. - When an owned collection is annotated, the check constraint is added to thecollection table orassociation join table.
- When an entity class is annotated, the check constraint is added to either theprimary table or to asecondary table, depending on which columns are involved in the constraint expression specified by
constraints().
For an entity withsecondary tables, a check constraint may involve columns of the primary table, or columns of any one of the secondary tables. But it may not involve columns of more than one table.
An entity may have multiple
@Checkannotations, each defining a different constraint.- See Also:
DialectOverride.Check
Required Element Summary
Required Elements Modifier and Type Required Element Description StringconstraintsThe check constraint, written in native SQL.