July 7-11, 2003  Portland, Oregon JDO (Java Data Objects) What It Is And Why It Matters Ron Hitchens JavaPolis.

Slides:



Advertisements
Similar presentations
V 6, Mats Strandberg ORM With Hibernate.
Advertisements

Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
January 30, 2014 Copyright Jim Farley Beyond JDBC: Java Object- Relational Mappings Jim Farley e-Commerce Program Manager GE Research and Development
Supporting Persistent Objects In Python Jeremy Hylton
Java and Databases PPJDG, May 2004 Chris Smith, MindIQ.
MANIPULATING DATA

JNDI Java Naming Directory Interface JNDI is an API specified in Java that provides naming and directory functionality to applications written in Java.
G O B E Y O N D C O N V E N T I O N WORF: Developing DB2 UDB based Web Services on a Websphere Application Server Kris Van Thillo, ABIS Training & Consulting.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
ASP.NET Programming with C# and SQL Server First Edition
ORM Object-Relational Mapping 1. Object Persistence Persistence is the ability of an object to survive the lifecycle of the process, in which it resides.
Java Data Object Che-Rung Lee. JDO Objectives Transparent persistence Range of implementations  embedded (J2ME)  two tier (J2SE)  enterprise (J2EE,
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
An Introduction to Hibernate Matt Secoske
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
Entity Beans BMP Celsina Bignoli
Chemical Toxicity and Safety Information System Shuanghui Luo Ying Li Jin Xu.
Java Persistence Frameworks No Fluff, Just Stuff 2003 By Bruce A. Tate J2Life, LLC.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
J2EE Structure & Definitions Catie Welsh CSE 432
1 LIBeLIS JDO verleiht Flügel Enterprise Information Access Scalable, robust JDO solutions « JDO: Just Do Objects ! » Alexander v. Zitzewitz
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Ch 2 – Application Assembly and Deployment COSC 617 Jeff Schmitt September 14, 2006.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.
PI Data Archive Server COM Points Richard Beeson.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
MCS 270 Spring 2014 Object-Oriented Software Development.
Middleware Technology (J2EE/EJB) Entity Bean (JBoss EJB 3.0 tutorial)
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Persistent State Service 1  Concept  Persistence is the ability of an object state to survive termination of the process in which the object executes.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 Nov 29, 2005 Object Relational Mapping Frameworks Wiene Höweler.
Session 1 Module 1: Introduction to Data Integrity
Object storage and object interoperability
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Introduction – ORM, Helloworld Application
G.Govi CERN/IT-DB 1GridPP7 June30 - July 2, 2003 Data Storage with the POOL persistency framework Motivation Strategy Storage model Storage operation Summary.
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
Using Datastore with JDO 1. Setting up DataNucleus Access Platform 2. JDO class enhancement 3. POJOs and JDO Annotations 4. PersistencyManager and its.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
The Holmes Platform and Applications
Don't Know Jack About Object-Relational Mapping?
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Open Source distributed document DB for an enterprise
Object-Oriented Databases
Introduction to J2EE Architecture
Chapter 12 Outline Overview of Object Database Concepts
Inventory of Distributed Computing Concepts and Web services
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Knowledge Byte In this section, you will learn about:
Developing and testing enterprise Java applications
Object Relational Mapping Tools
Presentation transcript:

July 7-11, 2003  Portland, Oregon JDO (Java Data Objects) What It Is And Why It Matters Ron Hitchens JavaPolis Antwerp, Belgium Dec 3, 2003 JavaPolis 2003 © 2003, Ronsoft Technologies

Purpose of this Presentation To give you an introduction to JDO and show that it represents a significant change in the way that Java applications will manage their data.

© 2003, Ronsoft Technologies Speaker Info  25+ years industry experience  6+ years using Java  Not a database expert  Built a website with JDO (  O’Reilly author (Java NIO)  Tech reviewer on JDO book (Russell & Jordan)

© 2003, Ronsoft Technologies Bye bye SQL JDO (or something like it) could revolutionize the way applications are created in the future.

© 2003, Ronsoft Technologies What is JDO?  Recently finalized Java standard extension JSR 12 (  Transparent object persistence No code changes to persisted objects Standardized API Vendor neutral Datastore neutral  Not an object database May use conventional RDBMS, OODB or other means to store object data - datastore

© 2003, Ronsoft Technologies JVM Datastore POJO SPI PM: Persistence Manager POJO: Plain Old Java Object* API: Application Programming Interface SPI: Service Provider Interface PM Persist Query JDO API JDO Impl * Implements PersistenceCapable at runtime

© 2003, Ronsoft Technologies How JDO Works  Transparent Persistence  Persistence by Reachability  Object Lifecycle  Inheritance  Identity  Queries  Metadata  Restrictions

© 2003, Ronsoft Technologies Transparent Persistence  Transparent to Persisted Objects No source code changes to needed to make objects persistent Clients are unaware an object is persistent Persisted objects are auto-loaded when referenced  Not Transparent to Entire Application JDO APIs are used to manage and query for objects Transaction boundaries affect persistent object state Object instances are per-PM – collisions in the datastore are possible at commit

© 2003, Ronsoft Technologies Transparent Data Access  Objects and object fields are lazy-loaded when referenced  Changes to object state result in eventual updates to datastore without explicit saves (subject to transaction boundaries)  PersistenceManager instances maintain object caches, datastore access is optimized where possible

© 2003, Ronsoft Technologies PersistenceCapable  The interface that all persistent objects must implement at runtime Byte code enhancement Source code pre-processing Direct implementation by programmer  PersistenceManager Primary access point to the JDO framework Operates on PersistenceCapable objects Maintains transaction context  StateManager Set per-object through the PersistenceCapable interface Manages an object’s state while persistent Mediates access to an object’s fields SPI hook into runtime JDO Implementation

© 2003, Ronsoft Technologies Mediated Object Access client:PersistenceManager myObject: PersistenceCapable implSM: StateManager makePersistent(myObject) jdoReplaceStateMananger(implSM) setFoo(12) setIntField (this, n, foo, 12) makeTransient(myObject) jdoReplaceStateMananger(null)

© 2003, Ronsoft Technologies Persistence By Reachability  A PersistenceCapable object instance is either persistent or transient at any given point in time  All objects referenced directly or indirectly by a persisted object are automatically made persistent at transaction commit. Persistence applies to the entire object graph Referenced non-PersistenceCapable objects are serialized to the datastore  Deletion from datastore is done per object, not by reachability No datastore garbage collection

© 2003, Ronsoft Technologies Simple JDO Example PersistenceManagerFactory factory = JDOHelper.getPersistenceManagerFactory(props); PersistenceManager pm = factory.getPersistenceManager(); Transaction trans = pm.currentTransaction(); User user = new User ("ron", "Ron Hitchens", Address addr = new Address (“123 Main St.”, “Somewhere”, “CA”, “12345”); user.setAddress (addr); trans.begin(); pm.makePersistent (user); trans.commit(); pm.close(); Two objects were persisted: The instance of User explicitly made persistent The Address instance reachable from user

© 2003, Ronsoft Technologies JDO Object Lifecycle (1) Persistent New Transient Persistent New Deleted Persistent Deleted Hollow Persistent CleanPersistent Dirty deletePersistent() Modify a fieldRead a field deletePersistent() Object retrieved from datastore, instantiated by JDOPOJO object instantiation Modify a field makePersistent() deletePersistent()

© 2003, Ronsoft Technologies JDO Object Lifecycle (2) Hollow Transient Persistent Clean Persistent Dirty Persistent New Persistent Deleted Transaction Completion commit(), rollback() commit() rollback() commit()

© 2003, Ronsoft Technologies Lifecycle Callbacks  An object may optionally implement the InstanceCallbacks interface jdoPostLoad(), jdoPreStore(), jdoPreClear(), jdoPreDelete()  May be used to release resources when an object is going hollow  May be used to reconstitute transient values that can be recalculated from persisted fields.  May be used to do cascading deletes  Couples the object to JDO

© 2003, Ronsoft Technologies Inheritance  Polymorphism is supported Base type must be PersistenceCapable Persistent super classes must be listed in metadata definition Queries may return subclasses, if requested  Implementation defines table mapping strategy Single Table, Class Table, Concrete Class Table  Interfaces may not be directly persisted

© 2003, Ronsoft Technologies JDO Identity  Each Persistent Object has a unique JDO Identity Not the same as Java identity JDO Identity is encapsulated as an Object One instance per identity per PersistenceManager Datastore Identity vs. Application Identity -Datastore Identity assigned automatically -Application Identity defined by programmer Persisted objects are retrieved by their identity

© 2003, Ronsoft Technologies Queries  Three ways of retrieving objects 1.Single object, by identity 2.Objects of a particular type – Extents 3.Objects whose fields contain specific values – Filters

© 2003, Ronsoft Technologies Queries – Single Object By ID Customer getCustomerByIdString (String idStr, PersistenceManager pm) { Object id = pm.newObjectIdInstance ( Customer.class, idStr); Object customer = pm.getObjectById (id, true); return ((Customer) customer); }

© 2003, Ronsoft Technologies Queries – Extent  A collection-like object representing a set of persistent objects, of a specified type, in the datastore  May contain subclasses, if requested Extent e = pm.getExtent (Customer.class, true); Iterator it = e.iterator() while (it.hasNext()) { Customer customer = (Customer) it.next(); customer.computeDailyInterest(); }

© 2003, Ronsoft Technologies Queries – Filters  Filters run against Extents Objects filtered are always of the type in the extent, possibly including subclasses  JDOQL – JDO Query Language Java-like syntax Parameters and variables may be supplied Datastore agnostic, references Java object fields  Filters are applied by the Query class Returns a collection of matched objects

© 2003, Ronsoft Technologies Queries – Filter Example Collection getCustomersByCity (City city, PersistenceManager pm) { Extent extent = pm.getExtent (Customer.class, true); String filter = “address.city == city”; Query query = pm.newQuery (extent, filter); query.declareParameters (“City city”); query.setOrdering (“name ascending”); return (query.execute (city)); }

© 2003, Ronsoft Technologies JDO Metadata  Provides mapping information to the JDO implementation about classes and fields  Standardized JDO descriptor (XML) Supplies information that cannot be determined by reflection Allows for override of defaults Provides for vendor extensions  Can be used to automatically generate a schema

© 2003, Ronsoft Technologies Datastore JDO Metadata JDO Impl Object WorldDatabase World JDO API POJO Object Types and RelationshipsHow and where to store object data

© 2003, Ronsoft Technologies JDO Restrictions  Not all objects are persistable Streams, Sockets, many system classes, etc  Collections must be homogenous Element type must be declared in metadata  Maps may have restrictions on key types  List ordering may not be preserved  Objects cannot migrate between PersistenceManager instances  Persisted objects cannot outlive their owning PersistenceManager No disconnect/reconnect semantics

© 2003, Ronsoft Technologies Why JDO Matters [1]  The Object Model IS the Data Model Datastore is one component in the system, not the center of the universe Promotes datastore independence at design, development and deploy times One language - no embedded SQL in the Java code  End-to-end OO design is possible – One system architecture  More agile – Datastore is an implementation detail

© 2003, Ronsoft Technologies Why JDO Matters [2]  Separation of Concerns Java Guy and DBA Guy do separate jobs No SQL strings buried in the Java code Leverage object persistence expertise of JDO implementors  Cost Standard API – Leverage developers Lightweight – No special container needed Competition among compliant vendors Legacy databases can be wrapped by JDO objects Less work to do overall (“Maximize the work not done”)

© 2003, Ronsoft Technologies JDO and EJB  Can JDO and EJB Co-exist? JDO can be used as a BMP strategy -Sun’s SunOne App Server uses JDO for CMP JDO can plugin to any JCA compliant App Server and participate in managed transactions Layered architecture -One app may use JDO objects directly -Another may use the same objects within EJBs to leverage other J2EE container services Using JDO/BMP may be more cost-effective than paying for full CMP capability Most Entity Beans uses are JDO-like anyway -Aren’t distributed -Don’t need access controls -Aren’t remote

© 2003, Ronsoft Technologies What’s Similar to JDO?  CMP  Proprietary O/R tools Toplink CocoBase Many others  Open Source O/R tools Hibernate* Torque OJB * Hibernate will have a JDO 2.0 binding

© 2003, Ronsoft Technologies Where Can I Get JDO?  JDO Vendors Solarmetric ( Libelis ( JDO Genie ( Poet FastObjects (  Open Source Options Apache OJB (db.apache.org/ojb/) JORM (  See for more

© 2003, Ronsoft Technologies Where Can I Get More Info?  Web Resources (search for JDO) Google “Java Data Objects”  Publications Java Data Objects (Russell & Jordan) - Java Data Objects (Roos)

© 2003, Ronsoft Technologies Questions? Ron Hitchens

© 2003, Ronsoft Technologies JavaPolis 2003