We compare standard JPA with native Hibernate, focusing on One-to-Many associations and session-based CRUD operations.

10.1. JPA Associations & Native Hibernate APIs

Definition: Bidirectional associations link entities. Native Hibernate APIs provide session-based alternatives to standard JPA interfaces.

Core Working Principles:

// Parent Department
@OneToMany(mappedBy = "department")
List<Employee> employees;

// Child Employee
@ManyToOne
@JoinColumn(name = "dept_id")
Department department;
5-Marks Exam Scoring Points
  • mappedBy property defines the child as the relationship owner.
  • @JoinColumn creates the foreign key column in the database table.
  • Session represents the active database connection context in native Hibernate.