zoukankan      html  css  js  c++  java
  • 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/

    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官网上没找到说明。网上找的。

  • 相关阅读:
    网络流24题-分配问题
    网络流24题-圆桌问题
    git ssh
    SQL Server 添加说明 语句
    问题思路
    数据库事务和锁
    Castle Windsor
    Flask学习笔记11之特殊的装饰器
    python中的"环绕通知"
    Flask学习笔记10之flash
  • 原文地址:https://www.cnblogs.com/xiluhua/p/4358335.html
Copyright © 2011-2022 走看看