Recall & Review
beginner
What does the @ManyToMany annotation represent in Spring Boot?
It represents a relationship where multiple records in one entity relate to multiple records in another entity, like students enrolled in many courses and courses having many students.
Click to reveal answer
intermediate
How do you define the owning side of a @ManyToMany relationship?
The owning side is the entity that controls the relationship and usually has the @JoinTable annotation to define the join table and join columns.
Click to reveal answer
intermediate
What is the purpose of the @JoinTable annotation in a @ManyToMany relationship?
It defines the join table that holds foreign keys linking the two entities, specifying the table name and the join columns for both sides.
Click to reveal answer
advanced
Why is it important to manage both sides of a @ManyToMany relationship in code?
Because changes to the relationship must be reflected on both entities to keep data consistent and avoid unexpected behavior.
Click to reveal answer
advanced
What happens if you omit the mappedBy attribute in a bidirectional @ManyToMany relationship?
JPA treats both sides as owning sides, creating two separate join tables, which can cause data duplication and confusion.
Click to reveal answer
In a @ManyToMany relationship, which annotation specifies the join table?
✗ Incorrect
The @JoinTable annotation defines the join table that links the two entities in a many-to-many relationship.
What does the mappedBy attribute do in a @ManyToMany relationship?
✗ Incorrect
mappedBy indicates the inverse side of the relationship and points to the field that owns the relationship.
Which side should have the @JoinTable annotation in a bidirectional @ManyToMany?
✗ Incorrect
Only the owning side defines the @JoinTable; the inverse side uses mappedBy.
What kind of database table does a @ManyToMany relationship create?
✗ Incorrect
A join table is created to link the two entities with foreign keys.
If you forget to update both sides of a bidirectional @ManyToMany in code, what might happen?
✗ Incorrect
Both sides must be updated to keep the relationship consistent in memory and database.
Explain how to set up a bidirectional @ManyToMany relationship between two entities in Spring Boot.
Think about how two friends share a group chat and both need to know about it.
You got /4 concepts.
Describe the role of the join table in a @ManyToMany relationship and how it connects the entities.
Imagine a guest list that shows which guests attend which parties.
You got /4 concepts.