Reputation: 535
Why doesn't the @ManyToOne
JPA specification have a mappedBy
attribute?
@ManyToOne
has both unidirectional and bidirectional relationships, but @OneToMany
has only unidirectional relationships. Why is that?
Upvotes: 5
Views: 1318
Reputation: 692121
Because the spec mandates that in a bidirectional OneToMany/ManyToOne association, the Many side must be the owner side (and thus doesn't need a mappedBy
attribute), and the One side must be the inverse side (and thus needs a mappedBy
attribute).
Upvotes: 7