Skip to Main Content
Enterprise JavaBeans 3.1, 6th Edition
book

Enterprise JavaBeans 3.1, 6th Edition

by Andrew Lee Rubinger, Bill Burke
September 2010
Intermediate to advanced content levelIntermediate to advanced
766 pages
18h 35m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans 3.1, 6th Edition

Chapter 11. Entity Relationships

Chapter 10 covered basic persistence mappings, including various ways to define primary keys as well as simple and complex property-type mappings. This chapter retools our employee registry a bit further by discussing the relationships between entities.

In order to model real-world business concepts, entity beans must be capable of forming relationships. For instance, an employee may have an address; we’d like to form an association between the two in our database model. The address could be queried and cached like any other entity, yet a close relationship would be forged with the Employee entity. Entity beans can also have one-to-many, many-to-one, and many-to-many relationships. For example, the Employee entity may have many phone numbers, but each phone number belongs to only one employee (a one-to-many relationship). Similarly, an employee may belong to many teams within his or her organization, and teams may have any number of employees (a many-to-many relationship).

The Seven Relationship Types

Seven types of relationships can exist between entity beans. There are four types of cardinality: one-to-one, one-to-many, many-to-one, and many-to-many. In addition, each relationship can be either unidirectional or bidirectional. These options seem to yield eight possibilities, but if you think about it, you’ll realize that one-to-many and many-to-one bidirectional relationships are actually the same thing. Thus, there are only seven distinct relationship ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
JavaServer Faces

JavaServer Faces

Hans Bergsten
EJB 3 Developer Guide

EJB 3 Developer Guide

Michael Sikora

Publisher Resources

ISBN: 9781449399139Errata Page