What is Hibernate?

Hibernate is an open-source Object-Relational Mapping (ORM) framework for Java that maps Java classes to database tables, letting developers work with objects instead of writing raw SQL for most persistence operations.

Key Points: • It converts Java data types to appropriate SQL types automatically, and vice versa when reading results. • Hibernate implements the JPA (Jakarta Persistence API) specification, so code written against JPA annotations is portable across ORM providers. • It manages the object lifecycle (transient, persistent, detached) and tracks changes to persistent objects automatically. • Provides its own query language, HQL, plus a programmatic Criteria API, in addition to native SQL support. • Includes caching, lazy loading, and transaction management out of the box, reducing boilerplate JDBC code.

Example: Instead of writing "INSERT INTO employee (name, salary) VALUES (?, ?)" by hand, a developer annotates an Employee class with @Entity and calls session.save(employee), and Hibernate generates and executes the SQL.

Interview Tip: A concise interview answer is:

"Hibernate is a Java ORM framework that maps Java classes to database tables, letting you persist and query objects instead of writing raw SQL. It implements the JPA specification and handles type conversion, caching, lazy loading, and transaction management for you."