Chapter 5. Working with Associations
In this chapter, we will cover the following recipes:
- One-to-one mapping using a foreign key association
- One-to-one mapping using a common join table
- One-to-one mapping using a common primary key
- One-to-many mapping or many-to-one mapping
- Many-to-many mapping
Introduction
An association represents the relationship between tables. There are two main types of associations: unidirectional and bidirectional. We will take a look at how to use associations with an example.
There are four main well-known types of relationships:
- One-to-one
- One-to-many
- Many-to-one
- Many-to-many
There are multiple ways to achieve these relationships.
Get Java Hibernate Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.