Beginning Pojo.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Sam-Bodden_596-3 FRONT.fm Page i Friday, February 24, 2006 9:59 AM Beginning POJOs From Novice to Professional ■■■ Brian Sam-Bodden Sam-Bodden_596-3 FRONT.fm Page ii Friday, February 24, 2006 9:59 AM Beginning POJOs: From Novice to Professional Copyright © 2006 by Brian Sam-Bodden 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 (pbk): 978-159059-596-1 ISBN-10 (pbk): 1-59059-596-3 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: Steve Anglin Technical Reviewer: Dilip Thomas Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Matt Wade Project Manager: Kylie Johnston Copy Edit Manager: Nicole LeClerc Copy Editor: Hastings Hart Assistant Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor: Susan Glinert Proofreader: Lori Bring Indexer: Michael Brinkman Artist: April Milne 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 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 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 www.apress.com in the Source Code section. Sam-Bodden_596-3 FRONT.fm Page iii Friday, February 24, 2006 9:59 AM I dedicate this book to my wife Anne for her unwavering love and support and to my two-year-old son Michael for putting a smile on my face every time I felt like quitting. Sam-Bodden_596-3 FRONT.fm Page iv Friday, February 24, 2006 9:59 AM Sam-Bodden_596-3 FRONT.fm Page v Friday, February 24, 2006 9:59 AM Contents at a Glance About the Author . xiii Acknowledgments . xv Introduction . xvii ■CHAPTER 1 Introduction . 1 ■CHAPTER 2 Eclipse . 23 ■CHAPTER 3 Building with Ant . 47 ■CHAPTER 4 Object Relational Mapping with Hibernate . 87 ■CHAPTER 5 Business Services with JBoss . 145 ■CHAPTER 6 The Spring Framework . 195 ■CHAPTER 7 Tapestry . 239 ■CHAPTER 8 Testing . 305 ■CHAPTER 9 Continuous Integration . 345 ■CHAPTER 10 Additional Topics . 363 ■INDEX . 381 v Sam-Bodden_596-3 FRONT.fm Page vi Friday, February 24, 2006 9:59 AM Sam-Bodden_596-3 FRONT.fm Page vii Friday, February 24, 2006 9:59 AM Contents About the Author . xiii Acknowledgments . xv Introduction . xvii ■CHAPTER 1 Introduction . 1 The Java EE Market . 1 Case Study: The TechConf Website . 3 Defining the Stakeholders . 4 The Business Problem . 5 General Application Requirements . 6 Attendees. 6 Presenters . 6 Sponsors . 7 Administrators. 7 Architectural Requirements . 8 Open Issues and Assumptions . 10 Assumptions . 10 Open Issues. 11 Design Road Map . 11 Finding and Refining Candidate Domain Model Elements . 13 Use Case Modeling . 16 Modeling Best Practices . 18 The Open Source Tools . 18 Useful Open Source Resources . 19 Summary . 20 ■CHAPTER 2 Eclipse . 23 Installing Eclipse . 24 Using Eclipse . 25 vii Sam-Bodden_596-3 FRONT.fm Page viii Friday, February 24, 2006 9:59 AM viii ■CONTENTS Creating an Eclipse Project . 26 Creating a Java Interface. 29 Creating a Java Class. 32 Running a Java Class . 34 Debugging a Java Class. 35 Eclipse Plug-ins . 36 Concurrent Versions System . 37 Understanding CVS. 37 CVS Concepts . 37 CVS in Eclipse . 38 Database Plug-ins . 40 SQL Explorer . 40 Web Development Plug-ins . 46 Summary . 46 ■CHAPTER 3 Building with Ant . 47 Introduction to Ant . 48 Obtaining and Installing Ant. 50 Ant’s Command-Line Options . 51 A Simple Ant Example . 52 More on Targets . 57 Target Dependencies . 58 Tasks . 61 Properties . 61 Datatypes. 63 Case Study: Building TechConf with Ant . 65 Compiling. ..