O'Reilly logo

Hibernate Recipes: A Problem-Solution Approach by GARY MAK, SRINIVAS GURUZU

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Many-to-One and One-to-One Mapping

In general, entities are related or associated to each other. For example, a Customer is associated with an Address. A Customer can have one or more than one Address (for example, Billing and Shipping). These relationships or associations are represented differently in a relational model and the domain/object model.

In a relational model, a foreign key column represents the dependency of one table on another. The Customer table has an AddressId as the foreign key column, which is the primary key of the Address table.

From the Customer perspective, because a Customer can have multiple addresses, so it's a many-to-one relationship. On the other hand, from the Address perspective, one address can belong ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required