Hibernate 4 Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

后端 未结 12 1906
青春惊慌失措
青春惊慌失措 2021-01-17 14:25

I am using Hibernate latest version 4.3.5.Final.

My hibernate.cfg.xml file content:



        
12条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 14:41

    Finally able to fix the issue, the issue is with the way SessionFactory is getting created.

    For a starter, official document is the first place to go and I must say that Hibernate official documentation seems to be not update with latest version changes.

    Fix is to apply the configuration settings to StandardServiceRegistryBuilder instance.

    // Create the SessionFactory from hibernate.cfg.xml
    Configuration configuration = new Configuration();
    configuration.configure("hibernate.cfg.xml");
    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
            .applySettings(configuration.getProperties()).build();
    SessionFactory sessionFactory = configuration
            .buildSessionFactory(serviceRegistry);
    

    Please refer my blog post here for more details.

提交回复
热议问题