From the course: Java Persistence API (JPA): 1 The Basics

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Relationships

Relationships - Java Tutorial

From the course: Java Persistence API (JPA): 1 The Basics

Start my 1-month free trial

Relationships

- [Instructor] There are relationships between Java classes and there's relationships between entities. As a Java developer, representing relationships between classes is straightforward. But how do you translate those relationships to entities? More often than not, entities need to reference other entities. We will look at how we map relationships and dependencies, between entities using JPA. The object oriented world consists of classes and associations between classes. There are classes where one object links to another object. These relationships between classes have direction and cardinality. They can be bidirectional or unidirectional. In a bidirectional relationship each entity has a relationship field or property that refers to the other entity. In a unidirectional relationship only one entity has a relationship field or property that refers to the other. The cardinality captures the aspect of how many entities exist on each side of the relationship. So entities on the source…

Contents