关于hibernate中报错”The content of element type "class" must match ......“的一点发现
来源:互联网 发布:易道打车软件 编辑:程序博客网 时间:2024/05/16 02:29
今天用hibernate测试subclass映射时发现了代码顺序影响程序运行的现象
- 会报错的代码如下
把配置辨别者列的代码放到其他property之后,例如:
<class name="Person" table="PERSONS" discriminator-value="PERSON"> <id name="id" type="java.lang.Integer"> <column name="ID" /> <generator class="native" /> </id> <property name="name" type="java.lang.String"> <column name="NAME" /> </property> <property name="age" type="int"> <column name="AGE" /> </property> <!-- 配置辨别者列 --> <discriminator column="TYPE" type="string"></discriminator> <!-- 使用subclass 进行子类映射 --> <subclass name="Student" discriminator-value="STUDENT"> <property name="school" type="string" column="SCHOOL"></property> </subclass> </class>
这个时候就会出现报错
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)*)".
- 不会报错的代码
当把配置辨别者列的代码直接放在id的配置之后,如下:
<class name="Person" table="PERSONS" discriminator-value="PERSON"> <id name="id" type="java.lang.Integer"> <column name="ID" /> <generator class="native" /> </id> <!-- 配置辨别者列 --> <discriminator column="TYPE" type="string"></discriminator> <property name="name" type="java.lang.String"> <column name="NAME" /> </property> <property name="age" type="int"> <column name="AGE" /> </property> <!-- 使用subclass 进行子类映射 --> <subclass name="Student" discriminator-value="STUDENT"> <property name="school" type="string" column="SCHOOL"></property> </subclass> </class>
这样就不会报错了,虽然不知道是什么道理,不过误打误撞把问题解决了。。
不知道有没有大神可以做出合理的解释
0 0
- 关于hibernate中报错”The content of element type "class" must match ......“的一点发现
- hibernate The content of element type "session-factory" must match "(property*,mapping*,(class-cache
- The content of element type "hibernate-mapping" must match "(meta*,typedef*,import*,(class|subclass|
- hibernate:newclass.hbm.xml文件错误(the content of element type "class" must match "(meta*,column*,type?generator?...)
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collectio
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache| collect
- "org.xml.sax.SAXParseException: The content of element type "class" must match" 异常解决
- The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tupli
- The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tupli
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache| collect
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collectio
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collectio
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache| c
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collectio
- ibatis:The content of element type "sqlMap" must match
- The content of element type "package" must match...
- The content of element type "struts-config" must match 解决方案
- The content of element type "package" must match 。。。。。。
- ZOJ - 2405 Specialized Four-Digit Numbers
- JavaScript服务器端初探
- Linux内核链表剖析
- ICSH 2015 (International Conference for Smart Health 2015
- android 分享到空间
- 关于hibernate中报错”The content of element type "class" must match ......“的一点发现
- 【多媒体封装格式详解】---MKV
- SAXReader saxReader = new SAXReader();来解析xml文件
- 博客将对一些安卓开源框架的解读,View,http,Image....等等
- 用两个队列模拟一个栈
- C++内存管理(可以参考C++与C#区别文章的后面部分)
- classpath、path、JAVA_HOME的作用
- 电力系统决策支持系统的构想
- UVA 11090 Going in Cycle!!(Bellman-Ford判断负圈)