Apress using and understanding java data objects jun 2003 ISBN 1590590430

649 90 0
Apress using and understanding java data objects jun 2003 ISBN 1590590430

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Using and Understanding Java Data Objects ISBN:1590590430 by David Ezzio Apress © 2003 This text provides an overview of JDO's specifications and behaviors in depth, covering the major application architectures, clientserver applications, Web applications, and applications that use Enterprise JavaBeans Table of Contents Using and Understanding Java Data Objects Introduction Chapter 1 - Basic Concepts in JDO Chapter 2 - Queries Chapter 3 - The Persistence Manage Chapter 4 - Transactions and Caching Chapter 5 - Enhanced Classes and Managed Fields Factories that Produce Persistence Chapter 6 Managers Chapter 7 - Helpers, Callbacks, and Exceptions Chapter 8 - Using JDO to Learn More Chapter 9 - Using JDO in a Swing Application Chapter 10 - Using JDO in a Web Application Chapter 11 - Using JDO in Enterprise JavaBeans Glossary Appendix A - Large UML Diagrams Index List of Figures List of Tables List of Listings List of Sidebars Back Cover Using and Understanding Java Data Objects is the programmer's guide to JDO Adopted by the Java Community Process, Java Data Objects (JDO) specifies a universal and transparent persistence service for Java objects JDO reduces the amount of code that application developers write to store and retrieve persistent state JDO frees application designers and programmers from the details of persistence As a result, designs can be more object-oriented, programmers can be more productive, and applications can be more robust and flexible This book provides you with the insight to evaluate and use JDO It begins by explaining the concepts and terminology of JDO It describes in detail the JDO interfaces and classes that you will use to build an application Throughout, the book probes in depth It identifies the specification's blemishes so you can avoid relying on behavior that is not defined It offers coding strategies to solve common problems It proposes working designs for common application architectures, such as client/server Swing applications, web applications, and five flavors of Enterprise JavaBeans The last four chapters provide a tutorial on the JDO Learning Tools, a suite of open source programs that explore JDO and exemplify its use Using the JDO Learning Tools, you can take a JDO implementation for a test drive and examine the architecture and code of several sample applications About the Author David Ezzio wrote his first application, which analyzed French elections, for a college professor in the sixties After a detour through philosophy and other pursuits, he has worked with software teams building desktop applications, character recognition software, and Internet-related software He has worked exclusively with Java since 1997 and is a Sun Certified Java Developer Dave founded his consulting practice, Yankee Software, in 1988 and helped found MaineJUG in 2001 He is a member of the JDO 1.0 maintenance group Dave holds a bachelor’s degree in mathematical logic from Yale University and a master’s degree in philosophy from the University of Chicago Using and Understanding Java Data Objects DAVID EZZIO Copyright © 2003 by David Ezzio All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN (pbk): 1-59059-043-0 Printed and bound in the United States of America 12345678910 Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Technical Reviewers: Regis Le Brettevillois, John Mitchell, Abe White Editorial Directors: Dan Appleman, Gary Cornell, Martin Streicher, Karen Watterson, John Zukowski Assistant Publisher: Grace Wong Project Manager: Tracy Brown Collins Copy Editor: Ami Knox Production Editor: Julianna Scott Fein Composition: Susan Glinert Indexer: Valerie Robbins Proofreader: Elizabeth Berry Cover Designer: Kurt Krames Production Manager: Kari Brooks Manufacturing Manager: Tom Debolski Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co KG, Tiergartenstr 17, 69112 Heidelberg, Germany In the United States: phone 1-800-SPRINGER, email , or visit http://www.springerny.com Outside the United States: fax +49 6221 345229, email , or visit http://www.springer.de For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710 Phone 510-549-5930, fax 510-549-5939, email , or visit http://www.apress.com The information in this book is distributed on an "as is" basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at http://www.apress.com in the Downloads section This book is dedicated to my wife, Theresa, and our daughters, Pearly and Sarah A man is a fish who swims in the sea of a woman's love About the Author David Ezzio wrote his first application, which analyzed French elections, for a college professor in the sixties After a detour through philosophy and other pursuits, he has worked with software teams building desktop applications, character recognition software, and Internet-related software He has worked exclusively with Java since 1997 and is a Sun Certified Java Developer Dave founded his consulting practice, Yankee Software, in 1988 and helped found MaineJUG in 2001 He is a member of the JDO 1.0 maintenance group Dave holds a bachelor's degree in mathematical logic from Yale University and a master's degree in philosophy from the University of Chicago In his free time, Dave hikes, rides his bicycle, reads history, and sails his Laser Tippity An occasional cook, he currently takes pride in his popovers He lives in Maine His e-mail address is About the Technical Reviewers Regis Le Brettevillois has cofounded LIBeLIS (Paris, France), one of the JDO vendors, where he is acting as CTO Before founding LIBeLIS, he was senior consultant for Versant, an ODBMS vendor He has been in charge of Java/Database architecture for customers like Banque Nationale de Paris and France Telecom Before this, he was consultant and R&D engineer for LM Informatique (Paris), OTI (Ottawa, Canada), and Andersen Informatique (Paris) Regis has been involved in various Java and Smalltalk projects in which object distribution and persistence technologies were strategic Regis has a postgraduate diploma in computer science from the University of Nantes John Mitchell is the founder of Non.net—a Technological Business Risk Management™ consulting practice Along with developing and rescuing distributed enterprise systems, John advises investors and executives on technology and high-tech companies Over the past 15 years, John has been the CTO of ElasticMedia, HealthLogic.com, jGuru, and the MageLang Institute He cowrote Making Sense of Java: A Guide for Managers and the Rest of Us and created the "Q&A" and "Tips & Tricks" columns at JavaWorld John is writing books on distributed systems, software development, and technological risk management Abe White is a senior software architect at SolarMetric (http://www.solarmetric.com) and is the original author of Kodo JDO (http://www.solarmetric.com/Software/Kodo_JDO/) He became interested in JDO while working in research and development at TechTrader, where he specialized in object/relational mapping, object/XML mapping, and Java Enterprise technologies Abe also has extensive experience with Java byte code manipulation, and is the creator of the open source Serp Bytecode Toolkit (http://serp.sourceforge.net) Abe was a founder of The Basement, a nonprofit entity based at Dartmouth College, his alma mater The Basement creates Web-based solutions for academia Abe is a member of the JDO Expert Group Acknowledgments A lot of people had a hand in making this book I thank all the folks at Apress who pulled everything together Particular thanks to Ami Knox, the copy editor; Tracy Brown Collins and Sofia Marchant, the tag-team project managers; John Zukowski, the Java editor and Visio wizard; and Gary Cornell, the publisher I thank Craig Russell, the JDO specification lead, and the other members of the JDO maintenance group for answering my questions and responding to my suggestions I thank my technical reviewers, Abe White, Regis Le Brettevillois, and John D Mitchell They labored long and hard, and their many comments made this book better than it would otherwise have been For an author, a book is more than a business proposition It is a labor of love and passion I thank all those who encouraged me in my work In particular, I thank my children, Pearly and Sarah, who frequently gave me impromptu encouragement Their love of books inspired me I thank my father, James Ezzio, and his wife, Mary, for their kind words and generous deeds Finally, I thank my wife, Theresa Her confidence in my abilities made the book possible Introduction Java data objects (JDO) specifies a transparent persistence service for Java objects The specification describes a general framework for storing and retrieving the persistent state of Java objects The JSR-12 expert group defined JDO using the Java Community Process JDO includes a specification, a reference implementation, and a technology compatibility kit (TCK) All three can be downloaded from the Java Community Process Web site (http://www.jcp.org/jsr/detail/12.jsp) A number of vendors have created implementations of JDO and provide versions of their products that you can download from the Web URLs to some of these vendors are found near the end of this introduction Java programmers use tools to make their projects successful Most applications and server-side components involve moving data between objects in memory and persistent storage JDO promises to change the way that Java programmers store and retrieve object state JDO simplifies the application's code, increases the application's portability, and helps to separate concerns in the application's design Compared to existing alternatives, JDO makes persistence easier to understand, easier to model, and easier to code Chapter 6: Factories that Produce Persistence Managers Table 6-1: Identifying Strings for the Supported Implementation Options Table 6-2: Simple Connection Properties Table 6-3: Connection Factory Properties Chapter 7: Helpers, Callbacks, and Exceptions Table 7-1: Five Methods That Detect an Object's JDO Management State List of Listings Chapter 1: Basic Concepts in JDO Listing 1-1: A Person and His or Her Dog Listing 1-2: Storing Modifications Upon Transaction Commit Listing 1-3: The Heffalump Class and Its Application Identity Class Chapter 2: Queries Listing 2-1: The Persistent Fields of the Foo and Bar Classes Listing 2-2: The Persistent Fields of the Song and Label Classes Listing 2-3: The Persistent Fields of the Library Classes Listing 2-4: The Relational Tables for the Library Classes Chapter 5: Enhanced Classes and Managed Fields Listing 5-1: Sample No-Arg Constructor for Typical Application Data Class Listing 5-2: Library Classes with Judicious Use of the transient Keyword Listing 5-3: A Shallow clone Method for an Application Data Class Listing 5-4: Simple JDO Metadata File Listing 5-5: The JDO Metadata for the Library Example Chapter 6: Factories that Produce Persistence Managers Listing 6-1: Getting a PersistenceManager from a Connection Factory Listing 6-2: Obtaining a PersistenceManagerFactory from JDOHelper Listing 6-3: Example of a Properties File Used to Obtain a PersistenceManagerFactory Listing 6-4: Code to Find a PersistenceManagerFactory in JNDI Listing 6-5: Finding a ConnectionFactory in JNDI Listing 6-6: Example of a CMT Session Bean That Uses JDO Listing 6-7: Example of a BMP Entity Bean That Uses JDO Listing 6-8: Example of Stateless BMT Session Bean That Uses JDO Listing 6-9: Example of Stateful BMT Session Bean That Uses JDO Chapter 7: Helpers, Callbacks, and Exceptions Listing 7-1: Transient State Dependent on Persistent State Listing 7-2: The Apple Class Captures the Identity String for a Datastore Identity Listing 7-3: Deleting a Banana Split and the Objects That Compose It Listing 7-4: Handling a Failed Optimistic Transaction Listing 7-5: Handling All Exceptions When Explicitly Using JDO Listing 7-6: Handling All Exceptions When Implicitly Using JDO Chapter 8: Using JDO to Learn More Listing 8-1: Expected Output from Running ant -projecthelp at the Command Line Listing 8-2: Expected Output from Running ant testjdohelper Listing 8-3: Expected Output from Running ant testfactory Listing 8-4: Expected Output from Running ant megacups Listing 8-5: Sample Output from the MegaCups Program Listing 8-6: Expected Output from Running ant library Listing 8-7: Example of Help Output from the Library Program Listing 8-8: User Commands to Find All the Categories That Interest Tom Listing 8-9: The Persistent Fields of the Apple Class Listing 8-10: Expected Output from Running ant statetracker Listing 8-11: Example of Help Output from the StateTracker Program Listing 8-12: User Commands to Create a New McIntosh Apple with Three Worms Listing 8-13: Sample Output from Committing the New McIntosh Apple Listing 8-14: Sample Output from Snooping on the Hollow Apple Chapter 9: Using JDO in a Swing Application Listing 9-1: Selected Output from Running ant rental-gui Chapter 10: Using JDO in a Web Application Listing 10-1: Expected Output from Building the clean-out Target Listing 10-2: Expected Output from Building the rental-servlet-opr Target Listing 10-3: Excerpt from maine.jsp Where the Rental Table Rows Are Generated Listing 10-4: The flipReservations Method of the ReservationService Listing 10-5: Implementation of the SupportsIdentityString Interface in the Rental Class Listing 10-6: Implementation of the SupportsVersion Interface in the Rental Class Listing 10-7: The equals and hashCode Methods for the Rental Application Data Class Chapter 11: Using JDO in Enterprise JavaBeans Listing 11-1: Excerpts of Expected Output from Building the rentalservlet-ejb Target Listing 11-2: Expected End of Output from Building the sayingsstateless-cmt Target List of Sidebars Chapter 1: Basic Concepts in JDO Defining Core Terminology ... List of Sidebars Back Cover Using and Understanding Java Data Objects is the programmer's guide to JDO Adopted by the Java Community Process, Java Data Objects (JDO) specifies a universal and transparent persistence service for... Dave holds a bachelor’s degree in mathematical logic from Yale University and a master’s degree in philosophy from the University of Chicago Using and Understanding Java Data Objects DAVID EZZIO Copyright © 2003 by David Ezzio All rights reserved... Java data objects (JDO) specifies a transparent persistence service for Java objects The specification describes a general framework for storing and retrieving the persistent state of Java objects The JSR-12 expert group defined JDO using the Java Community Process

Ngày đăng: 26/03/2019, 17:07

Mục lục

  • Using and Understanding Java Data Objects

  • The Advantages of JDO

  • A Short History of JDO

  • Fear, Uncertainty, and Doubt (FUD)

  • A Note on the UML Diagrams Used in This Book

  • How This Book Is Organized

  • Chapter 1: Basic Concepts in JDO

    • The Persistence Services of JDO

    • Managed and Unmanaged Objects

    • The Ten Management States of Data Objects

    • Identity and the Uniqueness Requirement

    • Chapter 2: Queries

      • The Extent Interface

      • The Design of JDO's Query Service

      • Factory Methods That Produce Query Objects

      • The Syntax of the JDO Query Filter

      • Using or Ignoring the Cache in a Query

      • SQL Queries That Can Be Mapped to JDOQL

      • Using SQL When JDOQL Is Not Sufficient

      • How JDO and JDOQL Help the Development Process

      • Chapter 3: The Persistence Manage

        • The Handling of null Values in Method Parameters

        • Obtaining and Closing a Persistence Manager

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan