Sunday, December 6, 2009

Hibernate 3.0: Sql Dialect must be explicitly set:(configuration error in hibernate 3.0)

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().
    //static final instance of SessionFactory

    or the following code which is the same but uses method chaining:-

    //static final instance of SessionFactory
    sessionFactory=new AnnotationConfiguration().

this will solve your Dialect or other errors related to configuration you might be facing.

No comments:

Post a Comment