Entity Mapping & Relationships In Spring Data JPA

    Question 1DATA JPA - @OneToOne Mapping

    Which of the following best describes a @OneToOne relationship in JPA?

    Question 2DATA JPA - Code Snippet (@OneToMany)

    What does the following mapping represent?

    @Entity public class Department { @Id private Long id; @OneToMany(mappedBy = "department") private List<Employee> employees; }

    Question 3DATA JPA - @ManyToOne Mapping

    In JPA, what is the typical use of @ManyToOne annotation?

    Question 4DATA JPA - Code Snippet (@ManyToMany)

    What is the effect of the following mapping?

    @Entity public class Student { @ManyToMany @JoinTable( name = "student_course", joinColumns = @JoinColumn(name = "student_id"), inverseJoinColumns = @JoinColumn(name = "course_id") ) private List<Course> courses; }

    Question 5DATA JPA - Cascade Types

    Which cascade type ensures that when a parent entity is removed, its related child entities are also deleted?

    Question 6DATA JPA - Code Snippet (FetchType.LAZY vs EAGER)

    What is the default fetch type for a @OneToMany relationship in JPA?

    @OneToMany(mappedBy = "department") private List<Employee> employees;

    Question 7DATA JPA - Bidirectional Relationships

    In a bidirectional relationship, why is the mappedBy attribute important?

    Question 8DATA JPA - Orphan Removal

    What happens when orphanRemoval = true is set on a relationship?

    Question 9DATA JPA - Code Snippet (JoinColumn)

    What will the following mapping create?

    @Entity public class Employee { @ManyToOne @JoinColumn(name = "dept_id") private Department department; }

    Question 10DATA JPA - Unidirectional vs Bidirectional

    Which statement correctly distinguishes between unidirectional and bidirectional entity relationships?