Chapter 14. Subtyping with Java EE

Table of Contents
1. Subtyping in Java
2. Case Study 1: Implement a Class Hierarchy with Single Table Inheritance
2.1. Make the Java Entity class model
2.2. New issues
2.3. Code the classes of the Java Entity class model
2.3.1. Summary
2.3.2. Code the enumeration type BookCategoryEL
2.4. STI database schema
2.5. Write the view and controller code
2.5.1. Summary
2.5.2. Add a segment information column in Retrieve/List All
2.5.3. Add a "Special type" select control in Create and Update
3. Case Study 2: Implement a Class Hierarchy with Joined Table Inheritance
3.1. Make the Java Entity class model
3.2. New issues
3.3. Code the model classes of the Java Entity class model
3.3.1. Define the category relationships
3.3.2. Database schema for joined table class hierarchy
3.4. Write the View and Controller Code
4. Run the App

In this chapter, we explain two case studies based on fragments of the information model of our running example, the Public Library app. In the first case study, we consider the single-level class hierarchy with root Book shown in Figure 12.1, which is an incomplete disjoint segmentation. We use the Single Table Inheritance approach for mapping this class hierarchy to a single database table.

In the second case study, we consider the multi-level class hierarchy consisting of the Person roles Employee, Manager and Author, shown in Figure 12.8. We use the Joined Table Inheritance approach for mapping this class hierarchy to a set of database tables that are related with each other via foreign key dependencies.

In both cases we show

  1. how to derive a Java Entity class model,

  2. how to code the Java Entity class model in the form of Java Entity classes,

  3. how to write the view and controller code based on the model code.