Annotation Type OneToMany


@Retention(CLASS) @Target(FIELD) public @interface OneToMany
Maps a collection of related entities using a join table 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
    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:
      LAZY
    • 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