2016-11-29 42 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不匹配。 –

相关问题