Hibernate映射"类"必须匹配

时间:2016-08-20 11:24:24

标签: java oracle hibernate

我有下一条消息错误,下面有红线

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)*)".

我尝试使用Oracle HR Scheme下一部分的映射文件创建POJO类。

Employees
Employee_id
first name
last_name
....
department_id

多对一

Departments
department_id
department_name
manager_id
location_id

多对一

Locations
location_id
...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping> 
<class name = "employee.Department" table="DEPARTMENTS">
<meta attribute="class-description">This class contains the department  records.</meta>
<id name = "id" type = "int" column="department_id"/>     
<many-to_one name="location" column = "location_id" 
        class = "employee.Location" not-null = "true"/>
</class>   
<class name = "employee.Location" table="LOCATIONS">
<meta attribute="class-description">This class contains the locations records.</meta>
<id name = "id" type = "int" column="location_id"/>
<property name="streetAdress" column = "street_adress" type = "string"/>   
<property name="postalCode" column = "postal_code" type = "string"/>   
<property name="city" column = "city" type = "string"/>   
<property name="stateProvince" column = "state_province" type = "string"/>   
<property name="country_id" column = "country_id" type = "string"/>   
</class>
</hibernate-mapping>

1 个答案:

答案 0 :(得分:0)

如错误消息所述,<class>标记可以包含多个子标记,但<many-to_one>(请注意 _ )不是允许的子标记。