What is the purpose of the Configuration class in Hibernate?

The Configuration class is Hibernate's entry point for bootstrapping the framework — it reads settings and entity mapping information and uses them to build a SessionFactory.

Key Points

Example

A standalone (non-Spring) Hibernate application typically does new Configuration().configure().addAnnotatedClass(Employee.class).buildSessionFactory() once at startup to wire everything together before opening any sessions.

SessionFactory sessionFactory = new Configuration()
        .configure("hibernate.cfg.xml")
        .addAnnotatedClass(Employee.class)
        .buildSessionFactory();

Interview Tip

A concise interview answer is

The Configuration class bootstraps Hibernate — it loads connection and mapping settings, typically from hibernate.cfg.xml, registers entity classes, and its buildSessionFactory() call produces the SessionFactory the rest of the application uses to open sessions.

Last updated: 16 July 2026

Previous question: What are the object states in Hibernate?

Next question: Describe the Second Level Cache in Hibernate.

More Hibernate (Optional) interview questions

All Hibernate (Optional) questions