Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

Chapter 4. Object/Relational Mapping

Entities do not exist in isolation and are usually associated with other entities. In this chapter we examine how to map these associations onto a relational database. We will cover the following topics:

  • One-to-one, one-to-many, and many-to-many associations.

  • Default object/relational mapping values.

  • Overriding the default object/relational mapping values.

  • The @Embedded, @Embeddable, @Enumerated, and @MapKey annotations.

  • Composite primary keys

  • Entity inheritance mapping strategies

O/R Mapping Default Behavior

In the previous chapter we saw how to persist individual entities to a relational database. In this chapter, we take a further look at object-relational mapping with EJB 3. In any real world application, entities do not exist in isolation but have relationships with other entities. In this chapter we shall see how these relationships are mapped onto a relational database.

Object-relational mapping is specified using annotations, but XML mapping files can...