Columns of primary keys should be mapped to persistent attributes. Like primary keys for tables, you need to set these persistent attributes as primary identifiers of entity classes. The mapped primary keys should be primary keys of primary tables.
There are three types of primary identifier mapping:
Simple primary identifier mapping - the primary key is associated with only one column and the mapped primary identifier has one persistent attribute mapped to the column.
Composite primary identifier mapping - the primary key is associated with more than one column and the mapped primary identifier has the same number of persistent attributes mapped to the columns.
Column(s) of primary keys can be mapped to associations (see Association Transformation). They are migrated from primary keys of other tables.
Component primary identifier mapping - multiple persistent attributes are encapsulated into a value type class, and the mapped primary identifier contains one attribute whose type is the Value type class.
Attributes of value type classes are mapped to columns, which are embedded in primary tables mapped by other entity classes. So you have to add primary tables of the containing classes as value type classes' mapping sources. If the value type class is used in more than one entity class, you should map each of its persistent attributes to multiple columns of tables of these classes.
For example, Value type class Address is used as attribute type for two classes, Product and Customer. The attributes of the Value type class Address can be mapped to columns of two tables, Company table and Customer table:
The mapping is easier to visualize in the Mapping Editor.
Primary identifier mapping is mandatory for entity classes.