- Create a hibernate.cfg.xml file and place it in root of the classpath and to initialize SessionFactory use the following code.
AnnotationConfiguration ac= new AnnotationConfiguration().
setProperties(System.getProperties());
ac.configure();
//static final instance of SessionFactory
sessionFactory=ac.buildSessionFactory();
or the following code which is the same but uses method chaining:-//static final instance of SessionFactory
sessionFactory=new AnnotationConfiguration().
setProperties(System.getProperties()).
configure().
buildSessionFactory();
this will solve your Dialect or other errors related to configuration you might be facing.