有没有人有一个功能性的cfg文件示例hibernate 4? 我可以在网上找到的所有参考文献的版本少于v4版,并且不起作用。我尝试粘贴我的文件的内容,但是这个网站删除了hibernate-configuration标签。休眠功能hibernate.cfg.xml 4
所以这里是什么出来:
<?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".
BUT的xmlns指定(的xmlns =“HTTP ://www.hibernate.org/xsd/hibernate-configuration“)
这是一个在汉堡4.1的错误?
看起来像问题是!DOCTYPE,但我不知道要设置它。如果我将它设置为引用v3 DTD的引用,那么它将无法再次解析,如果我不包含doctype,它会抱怨hibernate-configuration缺少xmlns属性......我极其沮丧地最后2 HRS – amphibient
Hibernate 4在线文档显示没有任何DOCTYPE的示例。 – amphibient
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch01.html#d5e83 – amphibient