gpt4 book ai didi

xml - hibernate 一对多列表映射错误

转载 作者:数据小太阳 更新时间:2023-10-29 02:16:41 25 4
gpt4 key购买 nike

我有以下 hibernate xml 映射文件段。

       <list name="networks" cascade="all">                <key column="parent_id"/>                    <one-to-many class="Network"/>        </list>

它产生了以下异常,为什么?它确实具有上述元素。

Caused by: org.xml.sax.SAXParseException: The content of element type "list" must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(index|list-index),(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)    at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)    at org.dom4j.io.SAXReader.read(SAXReader.java:465)    at org.hibernate.cfg.Configuratio

最佳答案

您需要添加 <list-index对于 <List > 是强制性的映射。

<list name="networks" cascade="all">
<key column="parent_id"/>
<list-index column="order" base="0" />
<one-to-many class="Network"/>
</list>

hibernate 引用文档

6.2.3. Indexed collections
All collection mappings, except those with set and bag semantics, need an index column in the collection table. An index column is a column that maps to an array index, or List index, or Map key.

关于xml - hibernate 一对多列表映射错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7033159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com