Complete the code to declare a one-to-one relationship in a Spring Boot entity.
public class User { @[1] private Profile profile; }
The @OneToOne annotation defines a one-to-one relationship between two entities.
Complete the code to specify the owning side of a one-to-one relationship with a join column.
public class User { @OneToOne @[1](name = "profile_id") private Profile profile; }
The @JoinColumn annotation specifies the foreign key column in the owning entity.
Fix the error in the mappedBy attribute to correctly define the inverse side of the one-to-one relationship.
public class Profile { @OneToOne(mappedBy = "[1]") private User user; }
The mappedBy value should be the name of the field in the owning entity that owns the relationship, here 'profile'.
Fill both blanks to complete the bidirectional one-to-one relationship between User and Profile.
public class User { @OneToOne @[1](name = "profile_id") private Profile profile; } public class Profile { @OneToOne(mappedBy = "[2]") private User user; }
The owning side uses @JoinColumn and the inverse side uses mappedBy with the owning side's field name.
Fill all three blanks to create a one-to-one relationship with cascade and fetch type settings.
public class User { @OneToOne(cascade = CascadeType.[1], fetch = FetchType.[2]) @JoinColumn(name = "profile_id") private Profile [3]; }
cascade = CascadeType.ALL applies all cascade operations, fetch = FetchType.EAGER loads the related entity immediately, and the field name is 'profile'.