How do you create SessionFactory in Hibernate?

To create SessionFactory object in Hibernate follow below steps:

Configuration cfg = new Configuration();
cfg.addResource("dir/hibernate.hbm.xml");
cfg.setProperties(System.getProperties());
SessionFactory sessionFactory = cfg.buildSessionFactory();

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.