Annotation Type NotFound


  • @Target({METHOD,FIELD})
    @Retention(RUNTIME)
    public @interface NotFound
    Indicates that a many to one, one to one, or many to many association maps to a column holding foreign keys, but without a foreign key constraint, and which may therefore violate referential integrity.

    The action() specifies how Hibernate should handle violations of referential integrity, that is, the case of an orphaned foreign key with no associated row in the referenced table:

    Note that this annotation has the side effect of making a to-one association non-lazy. It does not affect the laziness of a many-to-many association.

    This annotation implies ConstraintMode.NO_CONSTRAINT for the purposes of DDL generation. That is, no foreign key constraint will be included in the generated DDL.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      NotFoundAction action
      Specifies how to handle the case of an orphaned foreign key.
    • Element Detail

      • action

        NotFoundAction action
        Specifies how to handle the case of an orphaned foreign key.

        By default, an exception is thrown.

        Default:
        org.hibernate.annotations.NotFoundAction.EXCEPTION