jdeveloper 10g and oracle adf business components getting the most out of your data

45
JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data Avrom Roy-Faderman Senior Programmer November, 2005

Upload: yanka

Post on 04-Feb-2016

75 views

Category:

Documents


0 download

DESCRIPTION

JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data. Avrom Roy-Faderman Senior Programmer November, 2005. Agenda. J2EE, ADF, and JDeveloper Why Business Components? Reading Data Changing Data Transactions Demo Q&A. What Is J2EE?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

JDeveloper 10g and Oracle ADF Business ComponentsGetting the Most Out of Your Data

Avrom Roy-FadermanSenior Programmer

November, 2005

Page 2: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Agenda

• J2EE, ADF, and JDeveloper• Why Business Components?• Reading Data• Changing Data• Transactions• Demo• Q&A

Page 3: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

What Is J2EE?

• Java platform for multi-tier applications

• Open• Scalable• Traditionally difficult to use

3GL Much time spent on application

plumbing

Page 4: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Frameworks

• Library of classes Handle plumbing automatically XML files provide customization Can make Java more like a 4GL

Page 5: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF and MVC

Business Services

View (Web and Wireless Clients)

View and Controller (Desktop Clients)

Model

Controller (Web and Wireless Clients)

• Oracle ADF is a framework based on MVC architecture

Page 6: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF and MVC

ADF Business Components

ADF UIXADF Swing

ADF Data Bindings

Struts + ADF Extensions

• Oracle ADF is a framework based on MVC architecture

Page 7: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Agenda

• J2EE, ADF, and JDeveloper• Why Business Components?• Reading Data• Changing Data• Transactions• Demo• Q&A

Page 8: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Impedence Mismatch

•SQL•Tables, rows•Primary keys•Foreign keys•Transactions•GB, TB

•Java•Classes, instances•Memory references•Object members•Shared heap•100s of MB

Page 9: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF BC Bridges the Gap

•SQL•Tables, rows•Primary keys•Foreign keys•Transactions•GB, TB

•Java•Classes, instances•Memory references•Object members•Shared heap•100s of MB

Page 10: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF BC Functionality

• Reading data• Caching data• Writing data• Managing relationships• Managing transactions

Page 11: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

What they Don’t Do

• Create user interface (view)• Organize the flow of the

application (controller)

Page 12: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Agenda

• J2EE, ADF, and JDeveloper• Why Business Components?• Reading Data• Changing Data• Transactions• Demo• Q&A

Page 13: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Reading Data

• ADF View Objects

• ADF View Links

Page 14: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF View Objects

• Retrieve data from the database

• Manage caches of data• “View object definitions”

contain SQL queries and act as templates for “view object instances”

Page 15: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF View Objects

• Each view object instance can execute the SQL query and cache the results

Database

View object instance

View object instance

DataData

DataDataData

rows

DataData

DataDataView

rows

SQL queryData retrieval

Page 16: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

View Object Attributes

• Every query column maps to a view object attribute

• Those attributes are visible to the application

SELECT E.EMPLOYEE_ID, E.LAST_NAME, D.DEPARTMENT_ID, D.DEPARTMENT_NAMEFROM EMPLOYEES E, DEPARTMENTS DWHERE E.DEPARTMENT_ID = D.DEPARTMENT_ID

EmployeeId

LastName

DepartmentId

DepartmentName

Page 17: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

View Objects Don’t Write!

• Classes to do DML are too heavyweight if not needed

• Some query columns hard to map backwards

Page 18: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Reading Data

• ADF View Objects

• ADF View Links

Page 19: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF View Links

• “View link definitions”

relate a pair of view object

definitions

• View link definitions specify

master/detail relationships

between the SQL queries

Page 20: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF View Links

• View link definitions have

“Source” and “Destination”

attributes

• These attributes specify the

master-detail relationship Just like foreign key and primary key attributes

specify a foreign key relationship

Page 21: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF View Links

• A view link definition works like an additional WHERE clause applied to the detail

SELECT E.EMPLOYEE_ID, E.LAST_NAMEFROM EMPLOYEES E

EmployeesView(Master)

SELECT D.DEPARTMENT_ID, D.DEPARTMENT_NAME, D.MANAGER_IDFROM DEPARTMENTS D

DepartmentsView(Detail)

WHERE D.MANAGER_ID = :1

Source attribute

Destination attribute

Page 22: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Agenda

• J2EE, ADF, and JDeveloper• Why Business Components?• Reading Data• Changing Data• Transactions• Demo• Q&A

Page 23: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Changing Data

• ADF Entity Objects

• View and Entity Attributes

Page 24: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

ADF Entity Objects

• “Entity object definitions” correspond to database tables.

• Entity object definitions are templates for “entity object instances,” which correspond to table rows.

Page 25: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

View Objects and Entity Objects

• Instead of caching data themselves, view object instances can store data in entity object instances

Database

View object instance

View object instance

DataDataDataDatarows

DataDataDataViewrows

SQL query

DataDataDataEntity objectinstances

Data retrieval

Page 26: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

View Objects and Entity Objects

• The entity object instances can write back to the database

• Entity object definitions can specify validation rules

Database

View object instance

View object instance

DataDataDataDatarows

DataDataDataViewrows

DataDataDataEntity objectinstances

DML

Page 27: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Entity Object Attributes

• Every table column maps to an entity object attribute

EmployeeId

FirstName

LastName

Salary

EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY ...

Page 28: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Changing Data

• ADF Entity Objects

• View and Entity Attributes

Page 29: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

View and Entity Attributes

• Every view object attribute can map to an entity attribute

EmployeeId

FirstName

LastName

DepartmentId

EmployeeId

LastName

DepartmentId

DepartmentName

Page 30: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

One View, Many Entities

• One view object definition can map to multiple entity object definitions

EmployeeId

FirstName

LastName

DepartmentId

EmployeeId

LastName

DepartmentId

DepartmentName

DepartmentId

DepartmentName

ManagerId

LocationId

Employees

DepartmentsEmpDeptView

Page 31: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

One View, Many Entities

• Then each view row will map to multiple entity object instances

DataDataDataDataViewrows

DataDataDataDataEntity objectinstances

DataDataDataDataEntity objectinstances

Employees

Departments

Page 32: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

One Entity, Many Views

• Multiple view object definitions can map to a single entity object definition

EmployeeId

LastName

DepartmentId

DepartmentName

DepartmentId

DepartmentName

ManagerId

LocationId

EmpDeptView

DepartmentId

DepartmentName

LocationId

LocationName

DeptLocView

Page 33: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

One Entity, Many Views

• Then different view object instances can share data

DataData

DataDataView

rows

DataData

DataDataEntity object

instances

EmpDeptViewinstance

DataData

DataDataView

rows

DeptLocViewinstance

Page 34: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

SQL-Only View Attributes

• View attributes don’t need to map to entity attributes at all

• Then they must be read-only• E.g.: Caclulated query

columns

Page 35: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Read-Only View Objects

• Have only SQL-Only attributes

• Do not use entity objects at all

• Read-only access to data• But

Page 36: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Agenda

• J2EE, ADF, and JDeveloper• Why Business Components?• Reading Data• Changing Data• Transactions• Demo• Q&A

Page 37: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Application Modules

• Application modules package up

the data and present it to the

rest of the application

• The application always talks to

the business components

through the application module

Page 38: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Application Module Instances

• Each instance (user) of the

application will get its own

application module instance

• The application module instance

contains view object instances

• View object instances use entity

object instances to write

Page 39: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

The Data Model

• The view object instances in an application module instance are joined in master-detail relationships by “view link instances”

• The resulting tree is called the “data model”

Page 40: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

A Simple Data Model

Instance ofEmployeesViewInstance of

EmployeesView

Instance ofDepartmentsViewInstance of

DepartmentsView

Instance of DeptMgrLink

SELECT E.EMPLOYEE_ID, E.LAST_NAMEFROM EMPLOYEES E

SELECT D.DEPARTMENT_ID, D.DEPARTMENT_NAME, D.MANAGER_IDFROM DEPARTMENTS D

WHERE D.MANAGER_ID = :current_employee_id

Page 41: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

A More Complex Data Model

MasterInstance of

EmployeesViewMaster

Instance ofEmployeesView

DetailInstance of

DepartmentsViewDetail

Instance ofDepartmentsView

DetailInstance of

EmployeesViewDetail

Instance ofEmployeesView

IndependentInstance of

DepartmentsViewIndependentInstance of

DepartmentsView

Page 42: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Application Module Definitions

• Templates for application

module instances

• Specify which view object

and view link instances

should go in the data model

Page 43: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Data Consistency

• Each application module instance has its own set of view and entity caches

• Two locking mode choices “Pessimistic” locks (the default) acquired on DB

rows as soon as data is changed in the cache

“Optimistic” locks acquired just before

executing DML

Page 44: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Demo

Page 45: JDeveloper 10g and Oracle ADF Business Components Getting the Most Out of Your Data

Q & A