Let's take a look at the relationship between MANY-One, how to map.
This is a class diagram: The Employee class has a reference pointing to the Department class.
Table Structure:
CREATE TABLE EMP
SSN Char (10) PRIMARY Key,
DEP_NAME VARCHAR (255)
)
Create Table DEP
Name varchar (255) Primary Key
)
Mapping file content:
clas>
clas>
package>
om>
Interpretation:
1. , the Employee class has a field called Department, which is an instance of the Department of the Department. Column = "dep_name" indicates that the table of Employee uses the name of the name to dep_name to associate with the DEPARTMENT table. This dep_name is the column name in the EMPLOYEE table, actually associated with the primary key NAME of the table of departments.
2. The map of the representment class can be written.