1

我在 Eclipse Mars 中尝试使用 Hibernate Tool Code generation 时遇到了这个问题。我已经有方言hibernate.cfg.xmlsqljdbc4.jar包括在内。

org.hibernate.HibernateException: 'hibernate.dialect' enter code here must be set when no Connection available


休眠.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">123</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=Qlsach</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
 </session-factory>
</hibernate-configuration>


休眠.reveng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
  <table-filter match-catalog="QLSACH" match-schema="dbo" match-name="DanhMuc"/>
  <table-filter match-catalog="QLSACH" match-schema="dbo" match-name="sach"/>
</hibernate-reverse-engineering>
4

1 回答 1

0

我通过在 Hibernate 配置对话框的“Main”选项卡中将 Hibernate 版本从 5.1 更改为 4.3 解决了这个问题。

于 2016-05-24T04:46:02.730 回答