Multiplicities are of the following types:
One-to-one mapping defines a single-valued association to another entity that has one-to-one multiplicity. This relationship mapping use the
@OneToOne annotation on the corresponding persistent property or field.
An entity instance can be related to multiple instances of the other entities.
One-to-many relationships use the
@OneToMany annotation on the corresponding persistent property or field.
mappedBy element is needed to refer to the attribute annotated by ManyToOne in the corresponding entity:
A one-to-many association needs to map the collection of entities.
A many-to-one mapping is defined by annotating the attribute in the source entity (the attribute that refers to the target entity) with the
@JoinColumn(name="FK_name") annotation discribes a foreing key of a relationship.
The entity instances can be related to multiple instances of each other.
Many-to-many relationships use the
@ManyToMany annotation on the corresponding persistent property or field.
We must use a third table to associate the two entity types (join table).