Topic Page

Hibernate and JPA interview questions and answers.

Hibernate and JPA questions appear in many Java backend interviews because they reveal whether a candidate understands what really happens between Java objects, SQL, transactions, and persistence context behavior. This page pulls together the ORM topics that usually matter most.

What interviewers usually look for here

Strong Hibernate answers go beyond annotations. Interviewers often want to know whether you understand the persistence context, entity states, lazy loading, dirty checking, flushing, and how those mechanics translate into SQL queries and production bugs. This is also where candidates are often tested on trade-offs: convenience versus control, abstraction versus performance, and default behavior versus explicit tuning.

If you can explain why N+1 happens, when cascade settings are dangerous, and how optimistic locking protects concurrent updates, you usually sound much stronger than candidates who only know the API surface.

Representative Hibernate and JPA interview questions

  1. What is JPA and how does Hibernate relate to it?
  2. What entity states exist in Hibernate?
  3. What is the persistence context?
  4. What is dirty checking and how does it work?
  5. What is the difference between persist, merge, and save?
  6. What is lazy loading and when does it cause problems?
  7. What is the N+1 query problem?
  8. What do cascade types do and when can they be dangerous?
  9. What is the difference between optimistic and pessimistic locking?
  10. When does Hibernate flush SQL to the database?

Related pages