Package org.hibernate.annotations
Annotation 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:
NotFoundAction.EXCEPTION
specifies that this situation should be treated as an error, causing aConstraintViolationException
, andNotFoundAction.IGNORE
specifies that this situation should be tolerated and treated as if the foreign key were null.
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 ElementsModifier and TypeOptional ElementDescriptionSpecifies how to handle the case of an orphaned foreign key.
-
Element Details
-
action
NotFoundAction actionSpecifies how to handle the case of an orphaned foreign key.By default, an exception is thrown.
- Default:
- EXCEPTION
-