[Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
来源:互联网 发布:宿舍破解版路由器mac 编辑:程序博客网 时间:2024/05/21 22:46
使用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());
0 0
- [Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set——【hibernate 日常错误】
- 创建SessionFactory出错Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- Hibernate4.3.x Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- ExceptionInInitialize Access to DialectResolutionInfo cannot be null when 'hibernate.dialect'not set
- [Solved] HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’
- Connection cannot be null when 'hibernate.dialect' not set
- Connection cannot be null when 'hibernate.dialect' not set
- Connection cannot be null when 'hibernate.dialect' not set
- Connection cannot be null when 'hibernate.dialect' not set
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dia
- failed.org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hiber
- Hibernate Connection cannot be null when 'hibernate.dialect' not set错误
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set 解决方法
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set .
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
- Redis源码-数据结构之Adlist双端链表
- 如何下载旧版的ndk
- POJ2553 强连通出度为0的应用
- 腾讯数十亿广告的基础是精准实时推荐
- Android中Animation详解
- [Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- 运用椭圆画法,45行代码画出任意正多边形
- Ubuntu中安装tftp服务的方法
- html基础内容
- HDU 4421 Bit Magic (图论-2SAT)
- 黑马程序员——String小结
- 链表之快慢指针续
- Myeclipse下新建struts项目并运行
- 如果,你是一个爱逐臭争利