JPA Relationships Annotations
Relationships
define associations between entities. They are represented In Java code by attributes (persistent fields or properties) in persistent classes that hold a reference or a collection of references to other entities. Jakarta Persistence (JPA) provides annotations to configure relationships.
Relationship annotations
Use the following annotations to define the multiplicity and ownership of entity associations:
Defines a single-valued association with one-to-one multiplicity between two entities.
Defines a many-valued association with one-to-many multiplicity, representing a collection.
Defines a single-valued association where multiple entities reference a single target entity.
Defines a many-valued association with many-to-many multiplicity where the other both sides maintain collections of each other.
Note: Unlike other JPA implementations, ObjectDB does not require you to explicitly specify these annotations for simple relationships. However, using them is necessary to configure specific cascade behaviors and fetch policies.
Configuration enums
Configure how the persistence provider propagates operations and loads related data using
these enumerations:
Specifies which operations, such as PERSIST or REMOVE, propagate to associated entities.
Determines whether related data is loaded immediately (EAGER) or on-demand (LAZY).
Collection configuration
Configure
the ordering and mapping of collection-based relationships using these annotations:
Specifies the ordering of elements in a List-valued association at the time of retrieval.
Specifies the attribute in the target entity used as the map key for a Map-valued association.
For more details, see the Persistent Classes chapter in the ObjectDB manual.