DOC PREVIEW
UMD CMSC 838P - Using the Java Data Objects Specification

This preview shows page 1-2-16-17-18-34-35 out of 35 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Using the Java Data Objects Specification With the Enterprise JavaBeans EJB Specification Persistence Options for the Enterprise Craig Russell Architect Sun Microsystems Inc Session 3349 Presentation Goal Learn how to use Java Data Objects JDO technology together with the Enterprise JavaBeans EJB specification 2 Session 3349 Learning Objectives As a result of this presentation you will be able to Name three choices for Enterprise Computing Persistence Explain the access patterns for the JDBC API the JDO specification and Entity Beans Describe benefits of CMP JDO technology and the JDBC API as implementation alternatives 3 Session 3349 Craig Russell s Qualifications Specification Lead for Java Data Objects technology Java Specification Request 12 JSR 12 Transparent Persistence Architect at Sun Microsystems and currently implementing CMP using the Java DO specification Frequent contributor to public forum discussions on transparent persistence for the Java platform 4 Session 3349 You Think Programming Persistence TM for EJB Specification based Components EJB components Is Hard Work Maybe you haven t heard how JDO can make your life easier 5 Session 3349 Presentation Agenda What is Persistence Persistence Alternatives for the Enterprise Session Bean Facade Pattern Entity Bean Delegate Pattern Batch Programs 6 Session 3349 What Is Persistence Depends on your point of view From the programming perspective Long term storage of information after program end and From the database perspective Shared repository of information among programs Today s presentation focuses on the programming perspective 7 Session 3349 Persistence Differentiators Persistence Solutions address Data sharing among users Transactional access Portability of applications Ease of use productivity quality Database programming represents up to 30 of coding in a project 8 Session 3349 Persistence Alternatives File I O generally illegal in servers Serialization Java DataBase Connectivity JDBC API EJB specification Container Managed Persistence Transparent Persistence JDO 9 Session 3349 Serialization for Persistence Simple API on the surface writeObject readObject But Externalizable replaceObject No query No partial read or update All or nothing gets read written No transactions No sharing last update wins 10 Session 3349 JDBC API for Persistence Full access to SQL database functionality No domain object model Standard API but Not portable due to SQL variants Manual field by field storage of data Hand coded data transformations Same data appears multiple times in VM Little reuse of code data models 11 Session 3349 CMP Entity Beans Guaranteed portability Declarative query Simple domain object model No inheritance or complex data models Optimized database update strategy Automatic distribution and security are provided by EJB container 12 Session 3349 Java Data Object Technology for Persistence Simple API Extended query support Complex domain object model Inheritance complex data models Optimized database read update strategy Distribution and security are provided by EJB container 13 Session 3349 JDO Technology Interfaces PersistenceManager Application Query Transaction 14 Session 3349 Persistent Object Life Cycle Query factory Filter database extent Java boolean expression Transaction completion JDO Technology PersistenceManager Interface void makePersistent Object o void deletePersistent Object o Object getObjectById Object oid Transaction currentTransaction Query newQuery Extent ex String filter 15 Session 3349 JDO Technology Query Interface Object execute Object parameters Query filter Java programming language boolean expression e g name startsWith Research Navigation via Collection contains e g emps contains e e salary param0 16 Session 3349 JDO Technology Transaction interface Modeled on javax transaction UserTransaction commit rollback begin 17 Session 3349 Inheritance Example Subclasses inherit fields and methods from superclass Subclasses redefine methods and add fields and methods Mapping object model to database is transparent to programmer 18 Session 3349 Employee PTEmployee FTEmployee class Employee String name class PTEmployee extends Employee BigDecimal hourlyWage class FTEmployee extends Employee BigDecimal salary Inheritance With JDO Technology JDO implementation knows class of each persistent instance Automatic instantiation of the correct class query Navigation getObjectById 19 Session 3349 PersistenceManager pm pmf getPersistenceManager EmployeeKey ek new EmployeeKey empId Employee emp pm getObjectById ek here JDO automatically instantiates instance of the correct class emp computePaycheck Persistence in the Enterprise Java Servlet API JavaServer Pages JSP specification with JDBC API or JDO API Session Beans with JDBC API or JDO API BMP Entity Beans with JDBC API or JDO API CMP Entity Beans 20 Session 3349 Session Beans JSP Specification Java Servlet API With the JDBC API Result Set DataSource provides transactional Connection Connection returns ResultSet with data Session Bean extracts data from ResultSet Connection Session Bean JSP Servlet DataSource 21 Session 3349 Database Session Beans JSP Specification Java Servlet API With the JDBC API InitialContext ctx new InitialContext DataSource ds DataSource ctx lookup java comp env jdbc PersonnelDB Connection cx ds getConnection PreparedStatement st cx prepareStatement SELECT ID NAME SALARY FROM EMPLOYEE WHERE ID st setInt 1 empName ResultSet rs st execute String name rs getString 2 BigDecimal salary rs getBigDecimal 3 22 Session 3349 Session Beans JSP Specification Java Servlet API With the JDO API Persistent Instance Persistence Manager PersistenceManagerFactory provides transactional PersistenceManager PersistenceManager returns Persistent Instance Session Bean uses Persistent Instance methods Database Session Bean JSP Servlet PersistenceManagerFactory 23 Session 3349 Session Beans JSP Specification Java Servlet API With the JDO API InitialContext ctx new InitialContext PersistenceManagerFactory pmf PersistenceManagerFactory ctx lookup java comp env jdo PersonnelPMF PersistenceManager pm pmf getPersistenceManager EmployeeKey empKey new EmployeeKey empId Employee emp Employee pm getObjectById empKey String name emp getName BigDecimal salary emp getSalary 24 Session 3349 Session Beans JSP Specification Java Servlet API With Entity Beans Entity Bean Entity Bean Home provides transactional Entity Bean via finder method Session Bean uses Entity Bean methods


View Full Document

UMD CMSC 838P - Using the Java Data Objects Specification

Download Using the Java Data Objects Specification
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using the Java Data Objects Specification and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using the Java Data Objects Specification and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?