在偶然一次运行hibernate测试类的时候,出现如下错误,Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set,但是我明明在配置文件中配置了啊?
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
这是因为我在代码中使用了这种方式
SessionFactory sessionFactory = new Configuration().buildSessionFactory();
来获取sessionFactory,但是此种方式并不适用于使用xml配置文件的方式,所以将其改为 
new Configuration().configure().buildSessionFactory();即可,在调用configure()方法的时候,我们深入源码可以看到
 public Configuration configure()throws HibernateException
{
configure("/hibernate.cfg.xml");
return this;
}

该方法调用了使用默认名称的xml配置文件,所以就可以读取到了。

Hibernate Dialect must be explicitly set的更多相关文章

  1. Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml

    转自:http://www.cnblogs.com/wj-wangjun/archive/2009/10/21/1587624.html Hibernate SQL方言 (hibernate.dial ...

  2. 'hibernate.dialect' must be set when no Connection avalable’

    一个错误'hibernate.dialect' must be set when no Connection avalable ‘ 网上也有不少人遇到这种问题,看上去好像是跟Hibernate的方言有 ...

  3. Hibernate SQL 方言(hibernate.dialect)

    RDBMS Dialect DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB ...

  4. Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

    docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/) sta ...

  5. Hibernate SQL方言 (hibernate.dialect)

    数据库 hibernate方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect ...

  6. 'hibernate.dialect' must be set when no Connection avalable

    'hibernate.dialect' must be set when no Connection avalable 当连接不可用时,必须要设置Hibernate方言 搜索大多数的解决办法是:首先查 ...

  7. The dialect was not set. Set the property hibernate.dialect

    The   dialect   was   not   set.   Set   the   property   hibernate.dialect load hibernate.cfg.xml 出 ...

  8. 【方言】Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

    Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 几种 方言配置差异 <?xml v ...

  9. Grails连接外部数据库注意事项Could not determine Hibernate dialect for database name [Oracle]!

    初次使用Grails时,使用其内置数据库,一直不会出错,但迁移到外部数据库时会出错Could not determine Hibernate dialect for database name [Or ...

随机推荐

  1. Cisco Packet Tracer的使用(一)

    Cisco Packet Tracer 是由Cisco公司发布的一个辅助学习工具,为学习思科网络课程的初学者去设计.配置.排除网络故障提供了网络模拟环境.用户可以在软件的图形用户界面上直接使用拖曳方法 ...

  2. 2014.9.20CSS样式表

    一.前景与背景 background-color: 背景色,定义背景的颜色 background-image:url() 定义背景图片 background-attachment:fixed/scro ...

  3. 0617 python 基础04

    控制流--for 循环 >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 换行输出 >>> for i in range(1 ...

  4. python自学笔记(一)简单了解python

    脚本解释型语言的内部机制 python先将脚本编译成字节码文件(pyc,pyo) python虚拟机解释并运行字节码文件 编译型语言的内部机制 先将源代码编译成机器码(机器能读懂的代码),生成可执行文 ...

  5. iOS 相关职位要求整理版

    在拉勾上找了20家,BOSS直聘找了10家感兴趣的在招聘 iOS 程序员的公司,把职位要求整理了一下. 初创公司一般要求1年以上开发经验,成长型或者成熟型公司一般要求最低2年以上开发经验.这里针对的是 ...

  6. 《Java4Android视频教程》学习笔记(二)

    一:面向对象 1.对象 ①对象的使用方法 对象.变量 对象.方法 ②匿名对象 new A().方法 new A().变量 匿名对象会被分配到对内存中 java内存处理机制会对一定时间内无指针指向的对象 ...

  7. Sublime 插件安装、常用配置

    安装:sublime + 插件 安装Sublime: 官网:http://www.sublimetext.com/ 安装package control组件,之后我们会使用该组件给Sublime安装常用 ...

  8. poj 1684 Lazy Math Instructor(字符串)

    题目链接:http://poj.org/problem?id=1686 思路分析:该问题为表达式求值问题,对于字母使用浮点数替换即可,因为输入中的数字只能是单个digit. 代码如下: #includ ...

  9. oralce dg conf

    http://wenku.baidu.com/view/ea9fa16cdd36a32d73758168.html http://ylw6006.blog.51cto.com/470441/84181 ...

  10. openStack error infos 调试

    glance image-create --name "RuiCheck" --disk-format qcow2 --container-format bare --is-pub ...