`

The content of element type "class" must match "(meta*,subselect?,cache?,synchro

    博客分类:
  • SSH
阅读更多

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也需要按套路来,不然死很惨都不知道……

分享到:
评论
1 楼 aniyo 2017-01-19  

相关推荐

    mondrian学习资料

    - **Subselect与Subcube**:在MDX中,子集和子立方体(Subcube)用于从整个数据立方体中提取部分数据。Subselect可以用于定义一个独立的查询区域,而Subcube则是在主查询基础上切出的一个特定的数据区域。 5. **...

    hibernate学习笔记

    - **subselect**:可选属性,用于懒加载时定义一个 SQL 子查询。 - **lazy**:可选属性,默认为 `true`,表示是否懒加载集合。 - **sort**:可选属性,默认为 "unsorted",表示集合的排序方式。 - **inverse**:可选...

    hibernate关联映射的作用和常用属性解释

    - **`subselect-load`**:仅在读取关联时执行子查询。 - **`abstract`**:标识当前类是否为抽象类,默认为`false`。 ##### 2. `&lt;property&gt;`元素 - **`name`**:属性名。 - **`column`**:数据库表中的列名,默认为...

    Hibernate之数据加载方式

    - **Subselect Loading**:通过子查询加载关联对象,避免全表扫描。 ### 五、结论 理解并熟练运用Hibernate的数据加载方式是优化应用程序性能的关键。根据实际需求选择合适的加载策略,结合查询方式和关联加载优化...

    Hibernate Reference Documentation3.1

    Table of Contents Preface 1. Introduction to Hibernate 1.1. Preface 1.2. Part 1 - The first Hibernate Application 1.2.1. The first class 1.2.2. The mapping file 1.2.3. Hibernate configuration 1.2.4. ...

    hibernate延迟加载技术详细解

    - 当没有设置 lazy="false" 时,默认使用 Subselect Fetching,这种方式意味着对于每个主对象,Hibernate 都会先执行一次主查询,然后再为每一个主对象执行一次子查询来加载关联对象。 - 适用于需要加载的关联数据...

    How to solve the hibernate N+1 problem?

    5. **使用`@Fetch(FetchMode.JOIN)`或`@Fetch(FetchMode.SUBSELECT)`**:前者强制使用JOIN来获取关联数据,后者在父对象集合被初始化时执行子查询。 6. **使用`@NamedEntityGraph`**:JPA 2.1引入的新特性,允许...

    day36 07-Hibernate抓取策略:many-to-one上的抓取策略

    4. **Subselect Fetching**:这种策略在加载主实体时,同时执行一个子查询来获取关联对象。这种方式适用于关联数据需要复杂条件过滤的情况。 5. **@EntityGraph**:从Hibernate 4.3开始引入,允许我们定义图形化的...

    Flash_MX2004动画制作教程

    - **箭头工具**(Arrow Tool)、**精选工具**(Subselect Tool)和**套索工具**(Lasso Tool):主要用于选择对象。 - **箭头工具**:可以移动、旋转、缩放对象;通过单击、双击或拖拽选择对象。 - **精选工具**:...

    hibernate总结

    1. **通过 OID 加载**:通过对象的唯一标识符(OID)直接获取对象,如 `session.get(Users.class, 1);` 2. **HQL(Hibernate Query Language)/SQL 检索**:HQL 是一种面向对象的查询语言,与 SQL 类似但操作对象而...

    hibernate配置参数详解

    2. **`hibernate.transaction.factory_class` 和 `hibernate.transaction.manager_lookup_class`**: 定义事务处理方式。例如: ```properties hibernate.transaction.factory_class=org.hibernate.transaction....

    Visual C++ 编程资源大全(英文源码 表单)

    75.zip Transparent Window 透明的窗口(6KB)&lt;END&gt;&lt;br&gt;76,CenterMDIWnd_demo.zip Center CMDIChildWnds in the client area of the main frame window(151KB)&lt;END&gt;&lt;br&gt;77,TabbedMDI.zip A variation on ...

    Hibernate笔记

    - **Fetch="subselect"**: 类似于`LAZY`,但在加载关联对象时,会为每个关联对象执行单独的SQL查询。 - **XML配置示例**: ```xml &lt;set name="students" inverse="true" cascade="all" fetch="subselect"&gt; ...

    Hibernate关联关系hbm.xml中的相关属性

    5. `fetch`: 控制集合的加载策略,如`select`(默认)或`subselect`。 6. `order-by`: 对集合元素进行排序的SQL表达式。 最后,`&lt;many-to-many&gt;`标签用于定义多对多的关系,例如学生可以选择多个课程,课程也可以被...

    精通sql结构化查询语句

    以SQL Server为工具,讲解SQL语言的应用,提供了近500个曲型应用,读者可以随查随用,深入讲解SQL语言的各种查询语句,详细介绍数据库设计及管理,详细讲解存储过程、解发器和游标等知识,讲解了SQL语言在高级语言中...

    Hibernate one-to-many-annotation

    3. **子查询优化**:通过子查询优化关联查询,例如使用`@Subselect`注解创建一个基于子查询的实体类。 ### 五、最佳实践 1. **明确业务需求**:根据实际场景选择合适的级联操作和加载策略。 2. **合理设计关联**:...

    Hibernate多对一配置

    使用`@Fetch(FetchMode.SUBSELECT)`或`@BatchSize`可以改善这种情况。 7. **双向关联**:在某些情况下,你可能还需要在被引用方建立一个指向引用方的关联,这被称为双向关联。这时,你需要在被引用方的实体类上使用...

    hibernate子查询

    在Hibernate的`class`元素中,`subselect`属性允许我们指定一个SQL表达式,这个表达式的结果将被用作类的实例来源。这意味着我们可以将子查询封装到一个单独的对象中,然后在主查询中引用这个对象。以下是如何使用`...

    mybatis一对多性能优化demo

    &lt;collection property="orders" ofType="Order" javaType="ArrayList"&gt; ``` 这里,User类有一对多关系到Order类,`&lt;collection&gt;`标签内的配置表示User的orders属性是Order类型的集合。 在查询时,如果我们...

Global site tag (gtag.js) - Google Analytics