intermediateRelationships & Queries
Why does Hibernate default `@OneToMany` to `FetchType.LAZY` but `@ManyToOne` to `FetchType.EAGER`?
A `@ManyToOne` points to a single row, so eagerly loading it is cheap and usually needed anyway (e.g. an Order almost always needs its Customer). A `@OneToMany` can point to an unbounded collection, so eagerly loading it by default could silently pull thousands of rows for every parent fetched — Hibernate defaults it to lazy so you opt in explicitly when you actually need the collection.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
Why does Hibernate default `@OneToMany` to `FetchType.LAZY` but `@ManyToOne` to `FetchType.EAGER`?