用于hibernate 4的函数hibernate.cfg.xml

amp*_*ent 6 hibernate

有没有人有hibernate 4的功能cfg文件示例?我在网上找到的所有参考文献都是低于v4,但是不起作用.我尝试粘贴我的文件的内容,但这个网站删除了hibernate配置标记.

所以这是出来的:

<?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>
Run Code Online (Sandbox Code Playgroud)

一旦我改变了

<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">
Run Code Online (Sandbox Code Playgroud)

我得到这个例外:

Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 63; Attribute "xmlns" must be declared for element type "hibernate-configuration".
Run Code Online (Sandbox Code Playgroud)

但是指定了xmlns(xmlns ="http://www.hibernate.org/xsd/hibernate-configuration")

这是HIBERNATE 4.1中的一个BU ???

vec*_*tor 1

...无论如何,我最终让 IntelliJ 创建了存根文件,只是为了开始它(对于 hibernate 4.1):

<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
Run Code Online (Sandbox Code Playgroud)