What are the steps for creating a SessionFactory in Hibernate?

Steps to create a SessionFactory in Hibernate are:

  • Configuration: First create a Configuration object. This will refer to the path of configuration file.
  • Resource: Add config file resource to Configuration object.
  • Properties: Set properties in the Configuration object.
  • SessionFactory: Use Configuration object to build SessionFactory.


Configuration config = new Configuration();
config.setProperties( System.getProperties() );
SessionFactory sessions = config.buildSessionFactory();

Leave a Reply

Your email address will not be published. Required fields are marked *