6.6.3 Direction of relationships

A relationship includes a bi-directional relationship and a unidirectional relationship. When a bi-directional relationship is handled, a relationship has an owner and a non-owner. A unidirectional relationship only has an owner. The owner of a relationship can take decisions on updating a database relationship.

The following rules are applied to a bi-directional relationship:

A relationship annotation has a cascade attribute. If you specify the cascade attribute, you can propagate the operations for the entities even for the reference destination entities. However, you can specify REMOVE in the cascade attribute of the relationship annotation only for OneToOne or OneToMany. If cascade=REMOVE is applied for other relations, the operations might not function properly. For details on the cascade attribute when the entities have relationships, see 6.4.1(4) Propagation of operations to the entities.

Note
Cosminexus JPA Provider does not implement the check for maintaining the consistency of relationships during execution. Therefore, when you update the relationships during the execution of an application, even if the update causes an inconsistency in the relationships, no warning or exception occurs.

Note that when a value is fetched from the database with collection relationships such as OneToMany or ManyToMany, an empty collection is returned as the relationship value if the related entity does not exist.