[Hibernate] Access to Dialectresolutioninfo cannot is null when & #39;hibernate.dialect& #39; Not set

Source: Internet
Author: User

Use the following code on the hibernate official document to make this exception in the test times.

Org.hibernate.HibernateException:Access to Dialectresolutioninfo cannot is null when ' Hibernate.dialect ' not set

Package Org.hibernate.tutorial.util;import Org.hibernate.sessionfactory;import Org.hibernate.boot.registry.standardserviceregistrybuilder;import Org.hibernate.cfg.configuration;public Class Hibernateutil {    private static final Sessionfactory sessionfactory = Buildsessionfactory ();    private static Sessionfactory Buildsessionfactory () {        try {            //Create the sessionfactory from hibernate.cfg.xml< C4/>new Configuration (). Configure (). Buildsessionfactory (    new Standardserviceregistrybuilder (). build ());        }        catch (Throwable ex) {            //Make sure your log the exception, as it might be swallowed            System.err.println ("Initial Se Ssionfactory creation failed. "+ ex);            throw new Exceptionininitializererror (ex);        }    }    public static Sessionfactory Getsessionfactory () {        return sessionfactory;    }}


Later changes to the old version number such as the following code exception disappears:

Configuration cfg = new configuration (); Sessionfactory SF = Cfg.configure (). Buildsessionfactory (); Session session = Sf.opensession ();

However, the Buildsessionfactory method is deprecated in the new version number, and finally the solution is found:

Configuration cfg = new configuration (). Configure (); sessionfactory = Cfg.buildsessionfactory (new Standardserviceregistrybuilder (). Applysettings (Cfg.getproperties ()). build ());


There is no further abnormality in the test.



[Hibernate] Access to Dialectresolutioninfo cannot is null when & #39;hibernate.dialect& #39; Not set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.