The entities handle the relation between tables as a relationship. When you handle a relationship with an entity, the reference to another entity is stored as a field in the entity. In addition, set the following relationship annotations in the persistence property or instance variable that references an entity:
The following figure shows the relationship between entities and the relation between tables.
Figure 6-5 Relationship between entities and relation between tables
If the relationship annotation is not specified for referencing the entity, the operations will not function properly. Note that if the generic type is not used in the reference where collection is used, the target entity must be specified as the relationship target.
Instead of using an annotation, you can also define a relationship using the O/R mapping file. However, note that when a relationship is defined in the O/R mapping file and if the same definition is specified in the annotation, the definition in the annotation is overwritten.