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

     static {
try {
sessionFactory = new AnnotationConfiguration()
.configure().buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}

测试时出现Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

自己依赖的是hibernate-core-4.2.7.Final.jar

改成:

 Configuration cfg = new Configuration().configure();
ServiceRegistry serviceRegistry= new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();
sessionFactory = cfg.buildSessionFactory(serviceRegistry);

Hibernate官网上没找到说明。网上找的。

Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set的更多相关文章

  1. Connection cannot be null when 'hibernate.dialect' not set

    严重: Exception sending context initialized event to listener instance of class [org.springframework.w ...

  2. org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  3. Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  4. 正确决解Hibernate4.*中:Connection cannot be null when 'hibernate.dialect' not set

    <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hi ...

  5. Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFac

    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...

  6. Hibernate(三): org.hibernate.HibernateException: No CurrentSessionContext configured!

    Hibernate版本5.2.9 获取Session的方式是sessionFactory.getCurrentSession(); 比较老一些的版本使用的是sessionFactory.openSes ...

  7. hibernate报错org.hibernate.HibernateException: No CurrentSessionContext configured!

    org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.internal.Ses ...

  8. Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection

    1.错误描述 Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection[jdbc\:mysql\://loca ...

  9. Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from

    Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from     Hi ...

随机推荐

  1. Yii中配置单点登录 即多个子站同步登录

    研究Yii的同步登录大概2个多月,几乎查遍了网上所有资料和案例,但都不是很理想,最后摸索出整理出来以下配置方案. 以下配置文件在config.php中,所有需要同步的站点都需要填写.网上一些站点给出的 ...

  2. SQL将一张表中的数据插入到另一张表

    将表T_wz_wz中的部分数据插入到表t_wz_kc: ,,'Y' from t_wz_wz where yxbz='Y' --去重复 -- and wzid not in (select wzid ...

  3. ios-chart 不支持渐变的底色 --- 后面支持了渐变

    https://github.com/danielgindi/ios-charts/issues/186 后话,最近库更新了,可以支持渐变色

  4. wpf 面试题目

    初级工程师 解释什么是依赖属性,它和以前的属性有什么不同?为什么在WPF会使用它?什么是样式什么是模板绑定(Binding )的基础用法解释这几个类的作用及关系: Visual, UIElement, ...

  5. DTMF Stresstesting

    import threading,time,serial,sys from random import randrange   port_snd=14 port_recv=2 recnt=0 ser_ ...

  6. jdk安装与环境变量配置(一劳永逸)

    换了一个项目组做新的项目,新的机器,又得重新打环境,懒得去百度下,这里做个备份,下回直接看就行,如下 进行java开发,首先要安装jdk,安装了jdk后还要进行环境变量配置: 1.下载jdk(http ...

  7. C++Primer 第十章

    //1.标准库算法不仅可以应用于容器,还可以应用于内置数组,指针. //2.大多数算法都定义在头文件algorithm中.标准库还在头文件numeric中定义了一组数值泛型算法. //3.算法本身不会 ...

  8. 转:python webdriver API 之 获取对象的属性

    获取测试对象的属性能够帮我们更好的进行对象的定位.比如页面上有很多标签为 input 元素,而我们需要定位其中 1 个有具有 data-node 属性不一样的元素.由于 webdriver 是不支持直 ...

  9. 转:python webdriver API 之鼠标事件

    前面例子中我们已经学习到可以用 click()来模拟鼠标的单击操作,而我们在实际的 web 产品测试中 发现,有关鼠标的操作,不单单只有单击,有时候还要和到右击,双击,拖动等操作,这些操作包含在Act ...

  10. Java SE series:2. enhance your java basis! [doc chm: jdk6api Chinese reference]

    1. javaee(Web) and Android 2. how to use eclipse and break point debuging in eclipse, as to java web ...