OgilviePartners.com 1
Enterprise Object Persistence ~ with ~
Java Data Objects
Robin M. Roos
Principal Consultant
Ogilvie Partners Ltd
OgilviePartners.com 2
Topics
• What is JDO ?
• Where does it fit in Enterprise Architecture ?
• What’s new with JDO 2.0 ?
• Who is using JDO with WebSphere ?
• Where can I go for more information ?
OgilviePartners.com 3
Topics (reprise)
• Why Objects ?
• Why Persistence ?• Why Relational ?
• Why Determine Architecture First ?
• To be or not to be a Component?
• What is the Present ?• What is the Future ?
OgilviePartners.com 4
Why Objects ?
• Object Oriented Programming 101– Objects have State & Behaviour
• Java 101 (OO concepts)– Inheritance, Interfaces, Polymorphism,
Encapsulation
• Domain Driven Design– Use Objects to Model the Business Domain
• Collaboration Patterns– Distribute business logic amongst collaborators
OgilviePartners.com 5
Why Persistence ?
• If you model the domain with object graphs, how can you– store the object graphs– retrieve individual objects– navigate object references– handle object-relational impedance mismatch
• Whilst maintaining– appropriate visibility– polymorphism– architecture neutrality
OgilviePartners.com 6
Why Relational ?
• Datastore choice is core to Architecture– SQL 92 ?– Oracle 9i ?
– A particular ODBMS ?– An XML Repository ?– All of the above (and others besides) ?
OgilviePartners.com 7
Why Determine Architecture ?
• What in the world is this chap on ?
• Choice of underlying persistence infrastructure can constrain further architectural choices
OgilviePartners.com 8
To be or not to be a Component ?
• An object (or set thereof) which encapsulates logic and/or data and executes within a container on which it is reliant for service provision [J2EE]
• An object with identity, and the reachable graph of dependent objects, together constituting a recognized business concept or abstraction.
OgilviePartners.com 9
What is the Present ?
• JDO 1.0 (March 2001)– Transparent– Datastore agnostic– Polymorphic
– Transactional (Pessimistic, Optimistic, CMT)
– Architecture Neutral
• JDO 1.0.1 (February 2003)– JDOOptimisticFailureException– PersistenceManagerFactory.close()
OgilviePartners.com 10
Transparent & Testable
• J2EE– Clients interact through the container
• JDO– Clients interact with domain objects directly
OgilviePartners.com 11
Bytecode Enhancement
OgilviePartners.com 12
Client-ServerArchitecture
OgilviePartners.com 13
WebArchitectureOgilviePartners.com
OgilviePartners.com 14
EnterpriseArchitecture
OgilviePartners.com
OgilviePartners.com 15
Entity Bean Delegate
ArchitectureOgilviePartners.com
OgilviePartners.com 16
J2EE Compliance
• The JDO 1.0 specification mandates compliance with the J2EE 1.3 connector architecture and transaction manager.– Every JDO 1.0 compliant implementation
will work with every J2EE compliant application server.
– Required J2EE configuration info may be server-specific.
OgilviePartners.com 17
J2EE Integration - EJB
• Enterprise Component:– Looks up PMF in JNDI when EJBContext is set– CMT & BMT with UserTransaction
• Gets and closes PM from PMF within UserTransaction
– BMT with JDO Transaction• Gets PM from PMF outside UserTransaction
• Commit Transaction before closing PM
OgilviePartners.com 18
J2EE Integration - WEB
• Servlet Filter gets PMF at init time• Servlet Filter gets PM from PMF at request time
– Puts PM into request scope
– Begins transaction
• Web component uses PM from request scope• Servlet Filter commits transaction and closes PM
prior to returning response
OgilviePartners.com 19
WebSphere & JDO
• EJ Gallo, the Californian Wine Maker
• Amkor Technologies
• Harbor Freight Tools
OgilviePartners.com 20
What is the Future of . . . JDO ?
• JDO 2.0– Greatly improved JDOQL
• Aggregation, Projection
– Standardized Object-Relational Mapping– Standardized Fetch Groups
– Detached Operation– Miscellaneous
• Sequences, Long-lived Optimistic Transactions, Useful helper methods, Native Connection Exposure, etc.
OgilviePartners.com 21
. . . Object Oriented Design ?
OgilviePartners.com 22
. . . Enterprise Architecture ?
OgilviePartners.com 23
Parting Thoughts
• JDO is not an end in itself. Instead it is an enabling technology. We can finally apply best-practice in Object Oriented Design without undue constraint, and we can fully exploit the best of the services J2EE has to offer when doing so is appropriate.
OgilviePartners.com 24
Ogilvie Partnerswww.OgilviePartners.com