Annotation Type OneToOne


@Retention(CLASS) @Target(FIELD) public @interface OneToOne
Maps a single related entity with a unique owning foreign key, or an inverse mappedBy field.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Chooses operations to propagate to related entities.
    Controls relationship initialization.
    Names the owning Java relationship field on the target entity.
    boolean
    Allows an owning to-one relationship to be null.
    boolean
    Deletes a related entity removed from this one-to-one or one-to-many association at flush.
  • Element Details

    • fetch

      FetchType fetch
      Controls relationship initialization.
      Returns:
      fetch policy; EAGER for to-one and LAZY for collections by default
      Default:
      EAGER
    • cascade

      CascadeType[] cascade
      Chooses operations to propagate to related entities.
      Returns:
      cascade operations; empty by default
      Default:
      {}
    • mappedBy

      String mappedBy
      Names the owning Java relationship field on the target entity.
      Returns:
      owning field name, or empty for the owning side
      Default:
      ""
    • orphanRemoval

      boolean orphanRemoval
      Deletes a related entity removed from this one-to-one or one-to-many association at flush.
      Returns:
      true to delete orphans; false by default
      Default:
      false
    • optional

      boolean optional
      Allows an owning to-one relationship to be null.
      Returns:
      true by default; false makes the generated foreign key required
      Default:
      true