advancedRelationships — @OneToMany, @ManyToOne, @ManyToMany, Cascade & FetchType
What is JPA's actual default FetchType for @ManyToOne and @OneToOne, and why does that surprise people?
EAGER — unlike @OneToMany and @ManyToMany, which default to LAZY. This is a common, genuine gotcha: developers who assume every association defaults to lazy loading are surprised to find @ManyToOne/@OneToOne associations loading eagerly on every parent fetch unless explicitly overridden to LAZY.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response