6. Object-Relational Mapping
maps objects to relational databases maps relational databases to objects
a programming technique for converting data between incompatible
type systems in object-oriented programming languages
- WikiPedia
7. Why ORM ?
Full on
Objects of objects
Less DB Work The ORM World
Beans
Not much else
Procedural Object-Oriented
Classic Procedural
with DAO’s
More DB Work
8. How to use ORM
ORM have to allow the DB swap "on the fly"
to achieve, we need DI / IoC framework (Swiz)
a GenericDAO to be created to manage Business
Logic
a Persistent Data collection to reduce server
calls
supported with a Push Mechanism to be Sync
with Data Source & for Conflict Management
9. Data Access Object
DAO is used to
Each DAO
do CRUD
instance is
operations and
responsible for
access with
one primary
Database tables,
domain object
used to achieve
or entity.
encapsulation
an object that provides an abstract interface to some types of database
or persistence mechanism.
- WikiPedia
10. Why we need
GenericDAO?
Mostly we With
deal with GenericDAO, Unit testing
multiple VO’s Using MVC Framework, while dealing with the business is damn easy
to be queried n x VO, we end up with logic will be as we can
from service in generic inject values
layer. code.
nx nx
n x Events
Delegates Commands
11. Advantages
Increases
productivity
Apply DRY (Don’t
Repeat Yourself)
Principle
Reduces errors
Easy for Unit
Testing
12. Server DAO Model
Abstract Real World Example
Data Source SQL Table: Notes
Create, Read, Update, Delete Perform SQL Queries
Data Access Object Notes DAO
creates Maps SQL Records to
Delegates CRUD Operations to Delegates CRUD Operations to
Value Object NoteVO
Business Object Library Service
calls receives Communicates with
receives
Client Flex RIA
13. Client DAO Model
Abstract Real World Example
Push Push
Business Object Delegate Update Notes Beans Delegate Update
Create, Read, Update, Delete Perform functions
creates
PC DAO PC Generic DAO Service Results to
Delegates CRUD Operations to Delegates CRUD Operations to
VO NoteVO
Events Signals
dispatches receives dispatches
receives
View Skinnable Component
18. Thanks For
Twitter @nsdevaraj
GTalk nsdevaraj
Blog http://nsdevaraj.wordpress.com
Code https://github.com/nsdevaraj/SwizDAO
Web http://www.adamstudio.in