---
title: "The content of element type \"class\" must match \"(meta*,subselect?,cache?,synchro"
author: "aniyo"
date: "2017-01-19T13:44:45Z"
tags: []
categories: ["编程语言"]
slug: "the-content-of-element-type-class-must-match-meta-subselect-cache-synchro"
draft: false
lastmod: "2017-01-19T14:23:08Z"
id: 2354033
url: "https://aniyo.iteye.com/blog/2354033"
---

The content of element type "class" must match "(meta\*,subselect?,cache?,synchronize\*,comment?,tuplizer\*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)\*,((join\*,subclass\*)|joined-subclass\*|union-subclass\*),loader?,sql-insert?,sql-update?,sql-delete?,filter\*,fetch-profile\*,resultset\*,(query|sql-query)\*)".

 

```
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
	at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)
	at org.hibernate.cfg.Configuration.add(Configuration.java:488)
	at org.hibernate.cfg.Configuration.add(Configuration.java:484)
	at org.hibernate.cfg.Configuration.add(Configuration.java:657)
	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:695)
	at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:291)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
	... 181 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
	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.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)
	... 188 more
```

 

解决这个问题弄得我想死的心都有了，看上去还挺简单，这不XML有问题嘛，都写着Unable to read XML

所以先检查了Server 端所有的xml配置文件，什么hibernate啊，什么eventMapping啊，还有business,dao的xml都看了，没看出什么毛病

 

The content of element type "class" must match ……

从这个error log呢明显觉得是class元素的配置有问题，我以为是以前一向可能出现的问题，property写的时候写错啦，或者双引号之类的弄丢啦，检查了一大堆，最后借助百度对比其他的hibernate文件，方知自己sa缺了，把versionNo property位置放错了。手贱，没事换什么位置 ，放后面又不会好看点。。。。当时写的时候就觉得这属性应该给creat\_user,create\_date,update\_user,update\_date站在一起。结果呢，结果sa缺的找了一上午，也没解决问题，好在这会终于清醒了，oh，阿门……

 

```
<hibernate-mapping>
  <class dynamic-update="true" lazy="true" table="TMP_DK_ASSESSMENT_UPLOAD" dynamic-insert="true" name="com.shkco.adsr3.staticdata.vo.TmpDkAssessmentInfo">
    <id name="id" type="long" column="ID">
      <generator class="sequence">
        <param name="sequence">SEQ_DK_ASSESSMENT_UPLOAD_ID</param>
      </generator>
    </id>
    <version unsaved-value="undefined" name="versionNo" column="VERSION_NO" type="long"/>
    <property name="ccdRefId" column="CCD_REF_ID" not-null="true" type="long"/>
    <property name="dkReviewDate" column="DK_REVIEW_DATE" not-null="true" type="timestamp"/>
    <property name="createDate" column="CREATE_DATE" not-null="true" type="timestamp"/>
    <property name="createUser" column="CREATE_USER" not-null="true" type="long"/>
    <property name="updateDate" column="UPDATE_DATE" not-null="true" type="timestamp"/>
    <property name="updateUser" column="UPDATE_USER" not-null="true" type="long"/>
  </class>
</hibernate-mapping>
```

 

class里面的元素，id标签过了一定要是version,再是property,多之前就是因为把version放到了createDate前面，而自己全然不知，无知。。。。

记录长个记醒……

 

copy也需要按套路来，不然死很惨都不知道……