In J2EE Env Container will load Session factory from config for you.
But if you need to test it in stand alone mode you can load it like this example
Example for Load Hibernate Session Factory with Java Class
SessionFactory sessionFactory = new AnnotationConfiguration()
.addPackage("com.test")
.addAnnotatedClass(ExampleHibernate1.class)
.addAnnotatedClass(ExampleHibernate2.class)
.addAnnotatedClass(ExampleHibernate3.class)
.addAnnotatedClass(ExampleHibernate4.class)
.addResource("mytable.xml") //for hibernate mapping XML
.configure()
.buildSessionFactory();
You can use sessionFactory Object for work with hibernate Query