首页 > Web开发 > 详细

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

时间:2015-03-23 00:12:00      阅读:672      评论:0      收藏:0      [点我收藏+]

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

1     static {
2         try {
3             sessionFactory = new AnnotationConfiguration()
4                     .configure().buildSessionFactory();
5         } catch (Throwable ex) {
6             // Log exception!
7             throw new ExceptionInInitializerError(ex);
8         }
9     }

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

 

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

改成:

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

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

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

原文:http://www.cnblogs.com/xiluhua/p/4358335.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!