Show TOC Start of Content Area

Object documentation Mapping Relationship Fields  Locate the document in its SAP Library structure

Definition

Relationship fields are:

·        Fields with persistence capable class types

·        Fields with collection interface types such as java.util.Set, java.util.Collection, java.util.List, or java.util.Map that contain elements of persistence-capable class types (the element type is specified in the persistent metadata).

Note

Fields with type java.util.List and java.util.Map are currently not supported.

 

Use

Depending on the field type, relationships between persistence-capable classes in the object model can be one-to-one, one-to-many, many-to-one or many-to-many. Additionally, relations can be unidirectional or bidirectional. The concept of relationships in the relational model is bound to foreign keys between database tables. The relational model in general differs from the object model – for example, the foreign key for one-to-many relationship does not usually belong to the table mapped to the class with the relationship field, and join tables that are used for many-to-many relationships do not belong to a specific class.

In the following sections, only relationship fields of type java.util.Set are considered, that is, duplicates are not allowed. The reason for this is that set semantics is appropriate to SQL semantics regarding foreign keys and (unique) primary keys. Finally, relationship fields of type java.util.Collection with multiset semantics are considered.

There are seven convenient relationship patterns as combinations of relationships in the object model and relationships in the relational model:

·        Bidirectional, inverse and managed relationships

·        One-to-many bidirectional relationships

·        One-to-many unidirectional relationships

·        Many-to-one unidirectional relationships

·        Many-to-many bidirectional relationships

·        Many-to-many unidirectional relationships

·        One-to-one bidirectional relationships

·        One-to-one unidirectional relationships

See also:

 

·        Null values

·        Foreign key constraints

·        Multiset Semantics/Collections

 

 

End of Content Area