What is the owning side of a JPA relationship, and what is mappedBy for?
Short answer
The side holding the foreign key is the owning side (usually @ManyToOne); only that side is written to the DB. mappedBy marks the other side.
3 points to say:
- The foreign key is in the "many" table; that side owns it.
mappedBygoes on the side without the foreign key.- Write a helper method that sets both sides.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.