intermediateRelationships — @OneToMany, @ManyToOne, @ManyToMany, Cascade & FetchType

What does mappedBy actually do in a bidirectional @OneToMany/@ManyToOne relationship?

It marks the @OneToMany side as the inverse (non-owning) side, telling Hibernate the foreign key already lives on the other (@ManyToOne) side's table — so Hibernate doesn't create a separate join table for this relationship. Changes must be made (and persisted) via the owning side; mutating only the inverse side's collection without updating the owning side won't persist.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

What does mappedBy actually do in a bidirectional @OneToMany/@ManyToOne relationship?

Next Step

Continue to Why is defaulting every relationship to CascadeType.ALL a common real production mistake?← Back to all Spring Data JPA & Hibernate Mastery questions