在偶然一次运行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. javascript封装自定义滚动条方法,可自定义四个边框滚动条

    还是根据我的个人习惯封装了一个方法 setScroll({ box :父盒子DOM对象, content : 内容盒子DOM对象, scrollall : 滚动条大盒子DOM对象, scroll : ...

  2. Convert Sorted Array to Balanced Binary Search Tree (BST)

    (http://leetcode.com/2010/11/convert-sorted-array-into-balanced.html) Given an array where elements ...

  3. 安装爬虫scrapy

    使用easy_install安装scrapy,报错 error: Setup script exited with error: command 'gcc' failed with exit stat ...

  4. Do not go gentle into that good night

    Do not go gentle into that good night By:Dylan Thomas   Do not go gentle into that good night,Old ag ...

  5. printf不同格式表示法

    格式代码 A ABC ABCDEFGH %S A ABC ABCDEFGH %5S ####A ##ABC ABCDEFGH %.5S A ABC ABCDE %5.5S ####A ##ABC AB ...

  6. OSG消锯齿

    osg::DisplaySettings::instance()->setNumMultiSamples();   在osg+mfc下成功实现抗锯齿,在程序初始化的时候,即在osg控制类中,我的 ...

  7. spring集成mongodb封装的简单的CRUD

    1.什么是mongodb         MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. mongoDB MongoDB是一个介 ...

  8. java.lang.NoClassDefFoundError: javax/servlet/AsyncContext

    报错:java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 我认为你需要在Servlet API,而不是2.5.AsyncContext ...

  9. 求最小的k个数

    和高速排序有点类似,利用高速排序的划分算法, 划分算法见http://blog.csdn.net/buyingfei8888/article/details/8997803 依据int partiti ...

  10. GridView行编辑、更新、取消、删除事件使用方法

    注意:当启用编辑button时,点击编辑button后会使一整行都切换成文本框.为了是一行中的一部分是文本框,须要把以整行的全部列都转换成模板,然后删掉编辑模板中的代码.这样就能使你想编辑的列转换成文 ...