Skip to content
C

Java Interview Questions

JPA / Hibernate Interview Questions

Object-relational mapping in Java — the JPA specification and its most common implementation, Hibernate.

Question 1: What is JPA?

Ans

JPA, Jakarta Persistence, is a Java specification for object-relational mapping and persistence. It defines APIs and annotations for mapping Java objects to relational database data.

It reduces repetitive JDBC mapping code for applications that fit an ORM approach.

Example

java
@Entity class Student { @Id private Long id; private String name; }

Important Point

JPA is a specification; Hibernate is a popular implementation/provider.

Question 2: What is Hibernate?

Ans

Hibernate is an ORM framework and a common implementation of the Jakarta Persistence specification. It maps Java objects to relational database tables and manages persistence operations.

It can reduce manual SQL and result-set mapping for typical CRUD and relationship operations.

Example

java
@Entity class Employee { @Id @GeneratedValue Long id; String name; }

Important Point

ORM does not eliminate the need to understand SQL, indexes, transactions, and query performance.

Continue Your Preparation