2016-11-29 87 views
0

是的hbm.xml冬眠錯誤 - org.xml.sax.SAXParseException:元素類型的內容 「類」 都必須符合以下

<class name="Location" table="LOCATION"> 
    <cache usage="read-only" /> 

    <id name="location_cd" column="LOCATION_CD" /> 

    <property name="location_type_cd" column="LOCATION_TYPE_CD" not-null="true" /> 
    <property name="organization_id" column="ORGANIZATION_ID" not-null="true"/> 
    <property name="census_ind" column="CENSUS_IND"/> 



</class> 

莫非任何人都能幫助理解爲什麼會出現這個錯誤?

+0

經過與下面的完整HBM,這是整個文件的樣子:<!DOCTYPE hibernate-映射PUBLIC「 - // Hibernate/Hibernate映射DTD // EN」 「http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd」>

+0

您是否檢查過完全合格的類名稱(帶有包名稱的類名稱) –

回答

0

我認爲列的類型缺少

你應該改變這種像

<id name="id" column="LOCATION_CD" type="int"></id> 

or 

<id name="location_cd" column="LOCATION_CD" type="int" /> 
+0

我不認爲在映射xml中聲明類型是強制性的。 Hibernate的合理默認值可以自動識別屬性到列的映射。 – Ubercool

+0

可能是您的DOCTYPE中指定的DTD與您項目中存在的DTD不匹配。 –

相關問題