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

O/R Inheritance Mapping


Inheritance is a distinctive aspect of object oriented technology. Inheritance could not be utilized in earlier versions of EJB as an EJB 2.x entity bean cannot extend another EJB 2.x entity bean. With EJB 3, entities are more object oriented in that one entity can extend another. However, this leaves us with the matter of mapping entities in an inheritance hierarchy onto a relational database.

There are a number of strategies we can use to map an inheritance hierarchy onto relational database tables. As an example, suppose the Account class has CheckingAccount and SavingsAccount subclasses:

CheckingAccount and SavingsAccount extend the base Account class. As the names suggest, they are entities that represent checking accounts and savings accounts respectively.

SINGLE_TABLE Strategy

The first inheritance mapping option is the Single Table strategy. All the classes in a hierarchy are mapped to a single table. The table must have a discriminator column whose value for...