Could not parse mapping document: null (INPUT_STREAM)
org.hibernate.boot.InvalidMappingException: Could not parse mapping document: null (INPUT_STREAM)
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:46)
Caused by: org.hibernate.boot.MappingException: Unable to perform unmarshalling at line number 7 and column 13. Message: cvc-enumeration-valid: Value 'true' is not facet-valid with respect to enumeration '[false, proxy]'. It must be a value from the enumeration. : origin(null)
Caused by: javax.xml.bind.UnmarshalException: null
报错的意思是使用了未定义的枚举值true,就报错了
Ⅱ 分析首先看报错的源文件,定位到true这里:
<composite-id>
<key-many-to-one class="Xxx" lazy="true" name="Xxxx">
<column length="32" name="ID">
<comment>comment>
column>
key-many-to-one>
composite-id>
找到hibernate-core-5.0.11.Final.jar包,反编译看到文件-org.hibernate.xsd.mapping.legacy-mapping-4.0.xsd里的内容,找到composite-id的规范定义:
<xs:complexType name="CompositeIdType">
省略
<xs:element name="key-many-to-one" type="CompositeKeyManyToOneType"/>
xs:choice>
省略
xs:complexType>
再找key-many-to-one对应的CompositeKeyManyToOneType
的定义,进而找到:
<xs:attribute name="lazy" type="LazyEnum"/>
<xs:simpleType name="LazyEnum">
<xs:restriction base="xs:token">
<xs:enumeration value="false"/>
<xs:enumeration value="proxy"/>
xs:restriction>
xs:simpleType>
这里发现枚举值不包含true的。因此进行xml验证时报错了
Ⅲ 结论- 请不要使用没定义的枚举值
lazy="true"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)