Recall & Review
beginner
What does the @OneToOne annotation represent in Spring Boot?
It represents a one-to-one relationship between two entities, meaning each instance of one entity is linked to exactly one instance of another entity.
Click to reveal answer
intermediate
How do you specify the owning side in a @OneToOne relationship?
The owning side is the entity that contains the foreign key and uses the @JoinColumn annotation to specify the column that joins the two tables.
Click to reveal answer
intermediate
What is the purpose of the mappedBy attribute in a @OneToOne relationship?
It is used on the inverse side to indicate that the relationship is controlled by the other entity's field, avoiding duplicate foreign keys.
Click to reveal answer
advanced
Can a @OneToOne relationship be lazy loaded in Spring Boot?
Yes, by default @OneToOne is eager, but you can set fetch=FetchType.LAZY to load the related entity only when accessed.
Click to reveal answer
beginner
What happens if you don't specify @JoinColumn in a @OneToOne relationship?
Spring Boot will create a default foreign key column with a generated name, which might not match your database schema or naming conventions.
Click to reveal answer
In a @OneToOne relationship, which side owns the foreign key?
✗ Incorrect
The owning side is the entity with the @JoinColumn annotation that holds the foreign key.
What does the mappedBy attribute do in a @OneToOne relationship?
✗ Incorrect
mappedBy tells Spring Boot which field owns the relationship to avoid duplicate foreign keys.
How do you make a @OneToOne relationship load lazily?
✗ Incorrect
Setting fetch=FetchType.LAZY delays loading the related entity until it is accessed.
What is the default fetch type for @OneToOne in Spring Boot?
✗ Incorrect
By default, @OneToOne relationships are eagerly fetched.
If you omit @JoinColumn in a @OneToOne relationship, what happens?
✗ Incorrect
Spring Boot generates a default foreign key column name if @JoinColumn is not specified.
Explain how to set up a @OneToOne relationship between two entities in Spring Boot, including owning and inverse sides.
Think about which entity holds the foreign key and how to avoid duplicate keys.
You got /5 concepts.
Describe the difference between the owning side and the inverse side in a @OneToOne relationship.
Consider who 'owns' the link in the database.
You got /4 concepts.