SessionFactory is the thread-safe factory Hibernate uses to produce Session objects — it's built once from the Configuration and holds all the compiled entity mappings and settings needed to talk to a particular database.
A Spring Boot application typically wires up exactly one SessionFactory (or, via JPA, one EntityManagerFactory) as a singleton bean at startup, and every request or service method then calls it to get a fresh Session for that unit of work.
A concise interview answer is
SessionFactory is a heavyweight, thread-safe object built once from Hibernate's Configuration, and its job is to produce lightweight Session instances via openSession(). You create it once per application or data source and reuse it for the app's lifetime, unlike Session, which you open and close per unit of work.
Last updated: 16 July 2026
Previous question: What are the core components of Hibernate?
Next question: What is a Session in Hibernate?