The Definitive Guide to Db4o
Total Page:16
File Type:pdf, Size:1020Kb
The Definitive Guide to db4o ■■■ Jim Paterson, Stefan Edlich, Henrik Hörning, and Reidar Hörning The Definitive Guide to db4o Copyright © 2006 by Jim Paterson, Stefan Edlich, Henrik Hörning, Reidar Hörning 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-13: 978-1-59059-656-2 ISBN-10: 1-59059-656-0 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 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. Lead Editor: Jason Gilmore Technical Reviewer: Brian Breneman Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Project Manager: Kylie Johnston Copy Edit Manager: Nicole LeClerc Copy Editor: Liz Welch Assistant Production Director: Kari Brooks-Copony Production Editor: Ellie Fountain Compositor: Susan Glinert Stevens Proofreader: Linda Seifert Indexer: Valerie Perry Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. 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, e-mail [email protected], 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 Source Code section. Contents at a Glance About the Authors . xvii About the Technical Reviewer . xix Acknowledgments . xxi Introduction . xxiii PART I ■ ■ ■ Introduction and Concepts ■CHAPTER 1 Introduction to db4o . 3 ■CHAPTER 2 Object-Oriented Concepts . 17 ■CHAPTER 3 Comparing the Object and Relational Data Models . 31 ■CHAPTER 4 OODBMS Basics . 47 PART II ■ ■ ■ Working with db4o ■CHAPTER 5 Quick Start . 71 ■CHAPTER 6 Querying Objects . 95 ■CHAPTER 7 Working with Objects . 125 ■CHAPTER 8 Client/Server Mode . 195 ■CHAPTER 9 Transactions . 223 ■CHAPTER 10 Configurations and Tuning . 249 ■CHAPTER 11 Replication . 275 ■CHAPTER 12 Advanced Issues . 309 iii PART III ■ ■ ■ db4o in the Real World ■CHAPTER 13 From RDBMS to OODBMS . 363 ■CHAPTER 14 Technical Considerations When Using db4o . 393 ■CHAPTER 15 The Business Case for db4o . 409 ■APPENDIX A Working with the ObjectManager . 423 ■APPENDIX B Quick Reference . 435 ■APPENDIX C Bibliography . 449 ■INDEX . 453 iv Contents About the Authors . xvii About the Technical Reviewer . xix Acknowledgments . xxi Introduction . xxiii PART I ■ ■ ■ Introduction and Concepts ■CHAPTER 1 Introduction to db4o . 3 Transparent Persistence . 4 Object Databases . 5 db4o Basics . 6 Queries in db4o . 10 Native Queries. 10 Simple Object Data Access (SODA) . 12 The ObjectManager . 12 db4o Application Areas . 13 Complexity. 14 Mobility . 14 Connectivity. 14 The Open Source Advantage . 15 Structure of This Book . 15 Languages and Versions . 16 ■CHAPTER 2 Object-Oriented Concepts . 17 Objects . 17 Encapsulation and Information Hiding . 17 Responsibilities and Collaboration . 18 Messages. 18 v vi ■CONTENTS Classes . 18 Class Diagrams . 19 Creating a Class . 20 Creating an Object . 21 Sending Messages to Objects . 21 Class Types . 22 Inheritance . 22 Polymorphism . 24 Abstract Classes . 25 Interfaces . 25 Object Relationships . 27 is-a . 28 has-a . 28 uses-a . 29 Design Patterns . 29 ■CHAPTER 3 Comparing the Object and Relational Data Models . 31 Data Models . 31 First Generation . 32 Hierarchical Data Model. 32 Network Data Model. ..