Reputation: 177
I want to generate class from hibernate mapping file by hbm2java, but I get the following error:
SAXParseException; lineNumber: 11; columnNumber: 15; 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)*)".
The content of mapping file is:
01 <?xml version="1.0"?>
02 <!DOCTYPE hibernate-mapping PUBLIC
03 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
04 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
05
06 <hibernate-mapping package="test">
07
08 <class name="phone" table="phone">
09 <property name="studentid" column="student_id" type="integer"/>
10 <property name="phone" column="number" type="string"/>
11 </class>
12
13 </hibernate-mapping>
(Somehow eclipse doesnt show anything in the outline view ...)
Thanks in advance.
Cs
Upvotes: 0
Views: 140
Reputation: 692131
*
means: 0, 1 or more elements of the preceding type are expected.
?
means 0 or 1 element of the preceding type is expected.
Nothing means exactly one of the preceding type is expected.
So you need an id
or composite-id
element ((id|composite-id)
) before any property
element.
Upvotes: 1
Reputation: 19020
You are missing the id property which is mandatory (on top of the two property elements):
<class name="phone" table="phone">
<id column=...
Upvotes: 1