Synopses & Reviews
Harnessing Hibernate is an ideal introduction to the popular framework that lets Java developers work with information from a relational database easily and efficiently. Databases are a very different world than Java objects, and they often involve people with different skills and specializations. With Hibernate, bridging these two worlds is significantly easier, and with this book, you can get up to speed with Hibernate quickly.
Rather than present you with another reference, Harnessing Hibernate lets you explore the system, from download and configuration through a series of projects that demonstrate how to accomplish a variety of practical goals. The new edition of this concise guide walks you through Hibernate's primary features, which include mapping from Java classes to database tables, and from Java data types to SQL data types. You will also learn about Hibernate's data query and retrieval facilities, and much more.
By reading and following along with the examples, you can get your own Hibernate environment set up quickly and start using it for real-world tasks right away. Harnessing Hibernate teaches you how to:
- Perform Object/Relational mapping
- Work with persistent data from Java code
- Work with groups and relationships between objects
- Extend Hibernate's rich type support for your own needs
- Simplify query creation using criteria and examples
- Use the Hibernate Query Language (HQL) and understand how it differs from SQL
- Use Hibernate in conjunction with Spring
- Use Hibernate in conjunction with other packages, such as the Stripes web framework and the Eclipse IDE
Once you're past the first few chapters, you can jump to topics that you find particularly interesting or relevant. All background material and explanations of how Hibernate works and why is in the service of a focused task. Source code can be downloaded from the book's website.
If using SQL is an uncomfortable chore, Harnessing Hibernate offers you an effective and trouble-free method for working with the information you store in your applications.
About the Author
a senior software engineer at Berbee, with over ten years professional experience as a systems developer. He started designing with objects well before work environments made it convenient, and has a passion for building high-quality Java tools and frameworks to simplify the tasks of other developers.
Tim O'Brien is an active committer in the Jakarta Commons, a sub-project of the Apache Software Foundation's Jakarta project. As a consultant, Tim tries to encourage the adoption of open-source software, and nudge organizations to view community participation as an essential strategy. In addition to his professional responsibilities, he is a Bass/Baritone who sings frequently in the Chicagoland area. Tim discovered programming on a Basic Four, TRS-80, and Commodore 64 in his hometown of Wellesley, Massachusetts; subsequently, studying Computer Engineering at the University of Virginia
Ryan Fowler is a software engineer at Berbee in Madison, WI. He programmed Basic on Apple II machines for a while in elementary school at St. Stephen School in Grand Rapids, MI. He returned to coding in the computer science department at Alma College in Alma, MI while earning his bachelor's degree. Ryan skis, sails and rounds life out with some guitar playing when there's no snow or wind.
Table of Contents
Preface; How to Use This Book; Font Conventions; On the Web Site; How to Contact Us; Acknowledgments; Hibernate in a Hurry; Chapter 1: Installation and Setup; 1.1 Getting an Ant Distribution; 1.2 Check Your Java Version; 1.3 Getting the Maven Tasks for Ant; 1.4 Installing the Maven Tasks for Ant; 1.5 Using the HSQLDB Database Engine; 1.6 Using Hibernate Core; 1.7 Setting Up a Project Hierarchy; Chapter 2: Introduction to Mapping; 2.1 Writing a Mapping Document; 2.2 Generating Some Class; 2.3 Cooking Up a Schema; Chapter 3: Harnessing Hibernate; 3.1 Configuring Hibernate; 3.2 Creating Persistent Objects; 3.3 Finding Persistent Objects; 3.4 Better Ways to Build Queries; Chapter 4: Collections and Associations; 4.1 Mapping Collections; 4.2 Persisting Collections; 4.3 Retrieving Collections; 4.4 Using Bidirectional Associations; 4.5 Working with Simpler Collections; Chapter 5: Richer Associations; 5.1 Eager and Lazy Associations; 5.2 Ordered Collections; 5.3 Augmenting Associations in Collections; 5.4 Lifecycle Associations; 5.5 Reflexive Associations; Chapter 6: Custom Value Types; 6.1 Defining a User Type; 6.2 Defining a Persistent Enumerated Type; 6.3 Using a Custom Type Mapping; 6.4 Working with Persistent Enumerations; 6.5 Building a Composite User Type; Chapter 7: The Annotations Alternative; 7.1 Hibernate Annotations; 7.2 Annotating Model Objects; 7.3 An Alternate Approach; Chapter 8: Criteria Queries; 8.1 Using Simple Criteria; 8.2 Compounding Criteria; 8.3 Projection and Aggregation with Criteria; 8.4 Applying Criteria to Associations; 8.5 Querying by Example; 8.6 Property-Oriented Criteria Factories; Chapter 9: A Look at HQL; 9.1 Writing HQL Queries; 9.2 Selecting Properties and Pieces; 9.3 Sorting; 9.4 Working with Aggregate Values; 9.5 Writing Native SQL Queries; Playing Nice with Others; Chapter 10: Connecting Hibernate to MySQL; 10.1 Setting Up a MySQL Database; 10.2 Connecting to MySQL; 10.3 Trying It Out; 10.4 Looking at the Data; Chapter 11: Hibernate and Eclipse: Really Using the Hibernate Tools; 11.1 Installing the Hibernate Tools in Eclipse; 11.2 Creating a Hibernate Console Configuration; 11.3 More Editing Support; 11.4 The Hibernate Console Perspective; 11.5 Code Generation; 11.6 Mapping Diagrams; Chapter 12: Maven in More Depth; 12.1 What Is Maven?; 12.2 Installing Maven; 12.3 Building, Testing, and Running a Project; 12.4 Generating IDE Project Files using Maven; 12.5 Generating Reports with Maven; 12.6 A Maven Project Object Model; 12.7 The Maven Build Lifecycle; 12.8 Using the Maven Hibernate3 Plug-in; 12.9 Becoming a Maven Maven; Chapter 13: Put a Spring in your Step: Hibernate with Spring; 13.1 What Is Spring?; 13.2 Writing a Data Access Object; 13.3 Creating an Application Context; 13.4 Putting It All Together; Chapter 14: The Finishing Touch: Stripes with Spring and Hibernate; 14.1 Earn Your Stripes; 14.2 Prepare Tomcat; 14.3 Create the Web Application; 14.4 Add Stripes; 14.5 Dealing with Associations; Hibernate Types; Basic Types; Custom Value Types; "Any" Type Mappings; All Types; The Criteria API; The Criterion Factory; The Projection Factory; The Order Factory; The Property Factory; Hibernate SQL Dialects; Getting Fluent in the Local SQL; Spring Transaction Support; Using the Spring Framework's Transactional Annotation; Using a JTA Transaction Manager; Where to Go Next; Online Manuals; Books; Source Code; Dealing with Newer Releases; Getting Involved; Colophon;