PolymorphicVO JSF

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
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 Valid Person Types:
Job_ID – Employee
Salary – Customer
Hire_Date
Commission
Credit_Limit
Status
Shipping_Address
Credit_Card_No

4-4 Copyright © 2008, Oracle. All rights reserved.


Using Inheritance in the
Business Domain Layer

PersonEO
Name
Phone
MailingAddress
PersonType Discriminator column

EmployeeEO CustomerEO
JobId CreditLimit
Salary Status
Hire Date ShippingAddress
Commission CreditCardNo
raiseSalary() 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

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 1 PERS Denver Pam


PersonID
PersonTypeCode PersonEO
Single VO for
PersonAddress PersonID the base EO
PersonName PersonTypeCode and its
PersonAddress subtypes
PersonName

EmployeeEO CustomerEO

Salary CreditLimit

2 STAFF Houston Gary 4 CUST Boise Kate


3 STAFF Reno Glenn 5 CUST Chicago Jeff
6 CUST Paris Patrice

4 - 12 Copyright © 2008, Oracle. All rights reserved.


Creating a View Object
with Polymorphic Entity Usage

4 - 13 Copyright © 2008, Oracle. All rights reserved.


Using View Objects with
Polymorphic View Rows
PersonListVO
Name
Multiple VO:
Phone
One for each
MailingAddress
base EO and
PersonType
subtype
PersonEO ThePerson

EmployeeListVO CustomerListVO
Name Name
Phone Phone
MailingAddress MailingAddress
PersonType PersonType
Salary CreditLimit
ThePerson ThePerson

EmployeeEO 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 At run time, rows show


the data model: different attributes depending
on the discriminator:
1

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