我在 Eclipse Mars 中尝试使用 Hibernate Tool Code generation 时遇到了这个问题。我已经有方言hibernate.cfg.xml
,sqljdbc4.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>