[Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' n
Posted gavanwanggw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' n相关的知识,希望对你有一定的参考价值。
使用Hibernate官方文档上的下面代码进行測试时报出这个异常。
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be 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 new Configuration().configure().buildSessionFactory( new StandardServiceRegistryBuilder().build() ); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } }
后来改动成旧版本号的例如以下代码异常消失:
Configuration cfg = new Configuration(); SessionFactory sf = cfg.configure().buildSessionFactory(); Session session = sf.openSession();
可是无參的buildSessionFactory方法在新版本号中已经不推荐使用了,最后找到了解决的方法:
Configuration cfg = new Configuration().configure(); sessionFactory = cfg.buildSessionFactory(new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build());
以上是关于[Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' n的主要内容,如果未能解决你的问题,请参考以下文章
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when
Intent to Dial Pad 和 SMS APP 正在加载错误的号码
java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from
安装k8s出现 Failed to list *api.Node: Get http://192.168.144.131:8080...: dial tcp 192.168.144.131:8080
centos7 gitlab14搭建完成后,无法访问的问题处理(“error“:“badgateway: failed to receive response: dial unix /var/opt)
centos7 gitlab14搭建完成后,无法访问的问题处理(“error“:“badgateway: failed to receive response: dial unix /var/opt)