@Retention(CLASS) @Target({FIELD})

public @interface OneToMany

Maps a collection of related entities using a join table or an inverse mappedBy field.

Methods

public abstract FetchType fetch() default FetchType.LAZYControls relationship initialization.
public abstract CascadeType[] cascade() default {}Chooses operations to propagate to related entities.
public abstract String mappedBy() default ""Names the owning Java relationship field on the target entity.
public abstract boolean orphanRemoval() default falseDeletes a related entity removed from this one-to-one or one-to-many association at flush.

Method details

fetch

public abstract FetchType fetch() default FetchType.LAZY
Controls relationship initialization.

Returns

fetch policy; EAGER for to-one and LAZY for collections by default

cascade

public abstract CascadeType[] cascade() default {}
Chooses operations to propagate to related entities.

Returns

cascade operations; empty by default

mappedBy

public abstract String mappedBy() default ""
Names the owning Java relationship field on the target entity.

Returns

owning field name, or empty for the owning side

orphanRemoval

public abstract boolean orphanRemoval() default false
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