Core Concepts in Persistence Layer Design
( )
立
立
Nov 24 , 2003
Overview Reporter :
Agenda
Primary Focus
Introduction
Object –Relational Mapping Patterns How to Design a Robust Persistence
Layer for RDBMS
Conclusion
Future work
Primary Focus
O-R Mapping
–S.W.Ambler ‘s 24 O-R Mapping Patterns How to Design Persistence Layer –There are 4 strategies to Encapsulate
Persistence, we only interested in
Persistence Layer approach .
Introduction
What is “Persistence”?
What is “Transparent Persistence”?
Why JDBC is not enough ?
–Currently most software projects designed by OO methology but persisted with
RDBMS.
How to encapsulate RDBMS access ?
–Building a persistence layer
What is Persistence ?
Ability of an object to survive even current session or program terminate.
Source : W.Keller “Persistence Options for Object-Oriented
Programs”, JAOO 2003
Transparent Persistence
Transient Object : “Die”with the end of a process .
A persistence mechanism is
called ”Transparent“or “Orthogonal“if persistent objects can be treated the same with transient (non-persistent) objects in programming environment.
Source : W.Keller “Persistence Options for Object-Oriented Programs”, JAOO 2003
JDBC is not enough ! JDBC is NOT a persistence layer
–JDBC is more like
“Database connection
utilities”
–Persistence layers should
have interfaces at object
level , NOT SQL / Row
level!
Persistence Layer : 2 Aspects O-R mapping
Runtime Support
–Transaction
–Cache
–Connection management
–Persistence objects life-
cycle management
–…etc
Source : D.Smith, “Persistence Architectures for Web Services and J2EE Applications”,Java One 2002
Object/Relational Mapping Issues
Reporter :
The O-R Impedance Mismatch
OO languages have a rich set of features not present in RDBMS or flat files, like:
–Complex objects
–Object identity
–Encapsulation
–Types and Classes
–Class or Type Hierarchies
–Overriding, overloading and late binding
Object/Relational Differences
Technical Differences
Cultural Differences
Technical Differences
Object-oriented paradigm based on Engineering Principles
Relational paradigm based on Mathematical Principles
Objects are traversed through relationships
Relational paradigm joins data from tables
Technical Differences (cont)
Deceptive Similarities, Subtle Differences –A class model is a data model with behavior?
?Depicts a structure, and within it data and behavior are
both depicted
–A data model is merely a subset of a class model?
Cultural Differences
Object people and data people look at problems differently
The technical mismatch between object model and data model is worsened
Data models often fail to be good drivers for the object model.
Frustration within the organization causes higher turnovers
Solving the Impedance Mismatch
Technical mismatch can be overcome by educating yourself and team on both technologies.
Decouple object world from database access as much as possible
–Encapsulate it !
Cultural mismatch is harder to solve, but solvable .
Mapping Objects to Relational Databases
Brief Introduction to 24 Mapping patterns.
Shadow information.
How to map inheritance structures.
Due to the time constriant, we only provide some of most important mapping issues.