hibernate 不一樣版本的xml配置文件的不一樣寫法

1,Hibernate 3.6.0 的XML的頭:java

    <!-- hibernate.cfg.xml文件 -->
    <!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">spring

    <!-- hbm.xml文件 -->
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">app

    <!-- hbm.xml文件中也可使用這個 -->
    <!doctype hibernate-mapping public
        "-//hibernate/hibernate mapping dtd 3.0//en"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">dom


2,Hibernate 3.3.1 的XML的頭:ui

    <!-- hibernate.cfg.xml文件 -->
    <!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
   
    <!-- hbm.xml文件 -->
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">spa

 

 

頭不能寫錯,不然會拋以下異常:
Caused by: org.hibernate.HibernateException: Could not parse configuration: file:/E:/workspace/ItcastOA/WebRoot/WEB-INF/classes/hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1477)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:601)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 48 more
Caused by: org.dom4j.DocumentException: www.hibernate.org Nested exception: www.hibernate.org
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
    ... 53 more.net

相關文章
相關標籤/搜索