@ManyToOne Annotation
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface ManyToOne {
Class targetEntity() default void.class;
CascadeType[] cascade() default {};
FetchType fetch() default EAGER;
boolean optional() default true;
}
The options for the @ManyToOne annotation have the same meanings as in the @OneToMany annotation; the only difference is the addition of the optional boolean. This defines whether the association is optional. If it is set to false, a non-null relationship must always exist.
@ManyToOne(optional=false, fetch = FetchType.EAGER)
@JoinColumn( name="topic_id" )
Additionally Annotation @OneToMany:
@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "forumBean")
Источник:
http://www.informit.com/guides/content.aspx?g=java&seqNum=241
Немає коментарів:
Дописати коментар