@Retention(CLASS) @Target({FIELD})
public @interface ManyToOne
Maps a single related entity using a foreign key on the owning table.
Methods
public abstract FetchType fetch() default FetchType.EAGER | Controls relationship initialization. |
public abstract CascadeType[] cascade() default {} | Chooses operations to propagate to related entities. |
public abstract boolean optional() default true | Allows an owning to-one relationship to be null. |
Method details
fetch
public abstract FetchType fetch() default FetchType.EAGERControls 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
optional
public abstract boolean optional() default trueAllows an owning to-one relationship to be null.
Returns
true by default; false makes the generated foreign key required