Annotation Type Check


  • @Target({TYPE,METHOD,FIELD})
    @Retention(RUNTIME)
    @Repeatable(Checks.class)
    public @interface Check
    Specifies a check constraint to be included in the generated DDL.
    • When a basic-typed field or property is annotated, the check constraint is added to the column definition.
    • When a ManyToOne association is annotated, the check constraint is added to the join column definition.
    • When an owned collection is annotated, the check constraint is added to the collection table or association join table.
    • When an entity class is annotated, the check constraint is added to either the primary table or to a secondary table, depending on which columns are involved in the constraint expression specified by constraints().

    For an entity with secondary 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 @Check annotations, each defining a different constraint.

    See Also:
    DialectOverride.Check
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String constraints
      The check constraint, written in native SQL.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String name
      The optional name of the check constraint.
    • Element Detail

      • constraints

        String constraints
        The check constraint, written in native SQL.
      • name

        String name
        The optional name of the check constraint.
        Default:
        ""