I am a newbie to Java Persistence API and Hibernate.
What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API?
By default, for all collection and map objects the fetching rule is FetchType.LAZY
and for other instances it follows the FetchType.EAGER
policy.
In brief, @OneToMany
and @ManyToMany
relations does not fetch the related objects (collection and map) implicictly but the retrieval operation is cascaded through the field in @OneToOne
and @ManyToOne
ones.
(courtesy :- objectdbcom)