Annotation Interface ForeignKey


@Target(FIELD) @Retention(RUNTIME) @Documented public @interface ForeignKey
The annotation that can be placed on the entity fields. With the annotation, an entity field can be specified, to be handled as a foreign key. This means that if multiple records are being saved simultaneously, then the previously saved records will be searched for the last modified entity (specified in the annotation), and then setting its primary key to the field marked by the annotation. The annotated field, and the primary ID field of the entity specified in the annotation must have the same Java type. In all cases, during saving the record order will be taken into account, in this case it means that the specified entity must be saved before the entity containing the annotated field With the help of this method, the foreign key can be easily reformed for the java side persisting.
Since:
4.0
Author:
JBStrap
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The entity class, which has its primary id written in the annotated entity field.
  • Element Details

    • masterEntity

      Class<?> masterEntity
      The entity class, which has its primary id written in the annotated entity field.
      Returns:
      The entity class containing the primary ID