You may have used hibernate 2.x and in case you are getting error (Hibernate Dialect must be explicitly set, jdbc connection parameters must be specified, etc) by using the same code to initialize SessionFactory as you did before then there's a simple fix for that error.

  • 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.