在配置subclass的时候出现了
写道
[main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(26)
The content of element type "class" must match "(meta*,subselect?,cache?
,synchronize*,(id|composite-id),discriminator?,(version|timestamp)?,
(property|many-to-one|one-to-one|component|dynamic-component
|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,
((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?
,sql-update?,sql-delete?,filter*)"
The content of element type "class" must match "(meta*,subselect?,cache?
,synchronize*,(id|composite-id),discriminator?,(version|timestamp)?,
(property|many-to-one|one-to-one|component|dynamic-component
|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,
((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?
,sql-update?,sql-delete?,filter*)"
我的xx.hbm.xml配置是这样的:
写道
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
当我把discriminator删除掉的就正确了,可是又不符合定义子类映射的要求,所以 从google上搜索,包括查看hibernate-mapping-3.0.dtd,可以看到是到class的这一段描述:
写道
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*,
resultset*,
(query|sql-query)*
)>
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*,
resultset*,
(query|sql-query)*
)>
可以看到discriminator必须要在id的后面定义,所以把discriminator改到id后面就OK了,像这样:
写道
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">