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.

Egg.

Configuration config = new Configuration();
config.addResource(“testInstance/configuration.hbm.xml”);
config.setProperties( System.getProperties() );
SessionFactory sessions = config.buildSessionFactory();

Read the full book at www.amazon.com
Posted in Hibernate, Hibernate Interview Questions

Leave a Reply

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

*