有人有hibernate 4的功能cfg文件示例吗?我可以在网上找到的所有参考资料都低于 v4,这不起作用。我尝试在此处粘贴我的文件的内容,但该站点删除了休眠配置标签。
所以这就是结果:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/">
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration">
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- Assume test is the database name -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/foampile</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<!-- List of XML mapping files -->
<mapping resource="SiteRecord.hbm.xml"/>
</session-factory>
</hibernate-configuration>
一旦我改为
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
我得到这个例外:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 63; Attribute "xmlns" must be declared for element type "hibernate-configuration".
但是指定了 xmlns (xmlns="http://www.hibernate.org/xsd/hibernate-configuration")
这是 HIBERNATE 4.1 中的错误吗???