在偶然一次运行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. Win8.1重装win7或win10中途无法安装

    一.有的是usb识别不了,因为新的机器可能都是USB3.0的,安装盘是Usb2.0的. F12更改系统BIOS设置,我改了三个地方: 1.设置启动顺序为U盘启动 2.关闭了USB3.0 control ...

  2. 关于cell中添加子视图 复用重叠问题的解决方法

    问题本质:   因为你要添加的子视图并不是在自定义的cell中实现的,而是根据系统给的UITableViewCell这个类创建的实例,每次进图 cellForRow方法都会创建一个cell,每次都要创 ...

  3. 小技巧-Try Catch

    与多线程,业务逻辑等比较复杂的功能打交道时,免不了对部分有可能产生不可预期的代码进行异常捕获. 这种异常可能不处理,比如: try { } catch {} 但是如果一旦发生异常,在程序调试的时候,发 ...

  4. JQuery实战学习--在dreamweaver 8中配置Jquery自动提示

    最近在学习jQuery,然后在网上找到了自动提示的方法,记之. 1,首先下载jQuery_API.mxp这个扩展文件. 2,打开DW,点击命令-->扩展管理-->文件-->安装扩展, ...

  5. Android 电源系列小结s

    package com.ritterliu.newBatteryWidget; import android.app.Activity; import android.app.Service; imp ...

  6. JS行合并处理方法

    //行合并 function _w_table_rowspan(col){ _w_table_firsttd = ""; _w_table_currenttd = "&q ...

  7. [C++]Standing Ovation——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  8. sqlserver、mysql、oracle各自的默认端口号

    sqlserver默认端口号为:1433 URL:"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname" D ...

  9. 使用Qt 开发图形界面的软件(尘中远)

    3DSlicer, a free open source software for visualization and medical image computing AcetoneISO:镜像文件挂 ...

  10. 如何使用picasso 对Android图片下载缓存

    相比较其他,picasso的图片缓存更加简单一些,他只需要一行代码就可以表述:导入相关jar包 Picasso.with(context).load("图片路径").into(Im ...