【发布时间】:2023-03-19 19:43:02
【问题描述】:
我在 Eclipse Mars 中尝试使用 Hibernate Tool Code generation 时遇到了这个问题。我的hibernate.cfg.xml 中已经有方言,包括sqljdbc4.jar。
org.hibernate.HibernateException: 'hibernate.dialect' 没有可用连接时必须在此处设置输入代码
hibernate.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>
hibernate.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>
【问题讨论】:
-
你是如何尝试创建会话工厂的?您可以在此处添加该代码吗?
-
我还没有创建会话工厂。我只是创建项目,创建 cfg.xml、reveng.xml 并尝试生成 POJO 类和映射 xml 文件。我在 NetBeans 中完美地完成了这项工作,但在 Eclipse 中却没有。
-
在 eclipse mars 中你在哪里指定 reveng.xml ?我找不到在哪里可以添加它
标签: eclipse hibernate code-generation dialect