You are on page 1of 19

Using Inheritance in the Business Domain Layer

Copyright 2008, Oracle. All rights reserved.

Objectives
After completing this lesson, you should be able to do the following: Create a Business Component that extends another component Develop an Entity Object (EO) that implements subtypes Create polymorphic View Objects (VO)

4-2

Copyright 2008, Oracle. All rights reserved.

Agenda
Inheritance and Business Components Polymorphic View Objects

4-3

Copyright 2008, Oracle. All rights reserved.

Using Inheritance in the Business Domain Layer


Persons Name Phone Mailing_Address Person_Type_Code Job_ID Salary Hire_Date Commission Credit_Limit Status Shipping_Address Credit_Card_No

Valid Person Types: Employee Customer

4-4

Copyright 2008, Oracle. All rights reserved.

Using Inheritance in the Business Domain Layer


PersonEO

Name Phone MailingAddress PersonType

Discriminator column

EmployeeEO JobId Salary Hire Date Commission raiseSalary()

CustomerEO CreditLimit Status ShippingAddress CreditCardNo approveCredit()

4-5

Copyright 2008, Oracle. All rights reserved.

Creating a Business Component That Extends Another

4-6

Copyright 2008, Oracle. All rights reserved.

Inheritance Example
To set up inheritance, you need to determine: The discriminator column and values The common attributes and methods The attributes and methods that are specific to subtypes

4-7

Copyright 2008, Oracle. All rights reserved.

Creating the Base Entity Object in an Inheritance Hierarchy


1 2 3

4-8

Copyright 2008, Oracle. All rights reserved.

Creating a Subtype Entity Object

4-9

Copyright 2008, Oracle. All rights reserved.

Agenda
Inheritance and Business Components Polymorphic View Objects

4 - 10

Copyright 2008, Oracle. All rights reserved.

Using Polymorphic View Objects


You can use View Objects with: Polymorphic entity usage Polymorphic view rows

4 - 11

Copyright 2008, Oracle. All rights reserved.

Using View Objects with Polymorphic Entity Usage


PersonListVO PersonID PersonTypeCode PersonAddress PersonName 1 PERS Denver Pam Single VO for the base EO and its subtypes

PersonEO PersonID PersonTypeCode PersonAddress PersonName

EmployeeEO
Salary 2 STAFF Houston Gary 3 STAFF Reno Glenn

CustomerEO
CreditLimit 4 CUST 5 CUST 6 CUST Boise Chicago Paris Kate Jeff Patrice

4 - 12

Copyright 2008, Oracle. All rights reserved.

Creating a View Object with Polymorphic Entity Usage


1

4 - 13

Copyright 2008, Oracle. All rights reserved.

Using View Objects with Polymorphic View Rows


PersonListVO Name Phone MailingAddress PersonType ThePerson EmployeeListVO Name Phone MailingAddress PersonType Salary ThePerson EmployeeEO Multiple VO: One for each base EO and subtype

PersonEO

CustomerListVO Name Phone MailingAddress PersonType CreditLimit ThePerson CustomerEO

4 - 14

Copyright 2008, Oracle. All rights reserved.

Creating View Objects with Polymorphic View Rows: Defining the VO Hierarchy
First, set up the view object hierarchy:
1 2 4

3 Not pictured

4 - 15

Copyright 2008, Oracle. All rights reserved.

Creating View Objects with Polymorphic View Rows: Defining the VO Hierarchy
5 6

4 - 16

Copyright 2008, Oracle. All rights reserved.

Creating View Objects with Polymorphic View Rows: Defining Subtypes in the Data Model
Next, set up the subtypes in the data model:
1

At run time, rows show different attributes depending on the discriminator:

4 - 17

Copyright 2008, Oracle. All rights reserved.

Summary
In this lesson, you should have learned how to: Create a Business Component that extends another component Develop an EO that implements subtypes Create polymorphic View Objects

4 - 18

Copyright 2008, Oracle. All rights reserved.

Practice 4 Overview: Using Inheritance


These practices cover the following topics: Creating an inheritance hierarchy of entity objects Implementing different attributes and behaviors for entity object subtypes Creating a view object that displays all subtypes, with behavior dependent on the subtype Creating view objects that display different attributes depending on the subtype

4 - 19

Copyright 2008, Oracle. All rights reserved.

You might also like