Hibernate Quickly

Patrick Peak, Nick Heudecker

  • 出版商: Manning
  • 出版日期: 2005-08-16
  • 售價: $1,710
  • 貴賓價: 9.5$1,625
  • 語言: 英文
  • 頁數: 220
  • 裝訂: Paperback
  • ISBN: 1932394419
  • ISBN-13: 9781932394412
  • 相關分類: Java 相關技術
  • 已絕版

買這商品的人也買了...

相關主題

商品描述

Description:

"I highly recommend this book."
- Christopher Haupt, Senior Engineering Manager, Adobe Systems Inc.

"If you want to learn Hibernate quickly, this book shows you step by step."
- Sang Shin, Java Technology Architect, Sun Microsystems

Positioned as a layer between the application and the database, Hibernate is a powerful object/relational persistence and query service for Java. It takes care of automating a tedious task: the manual bridging of the gap between object oriented code and the relational database. Hibernate Quickly gives you all you need to start working with Hibernate now.

The book focuses on the 20% you need 80% of the time. The pages saved are used to introduce you to the Hibernate "ecosystem": how Hibernate can work with other common development tools and frameworks like XDoclet, Struts, Webwork, Spring, and Tapestry.

The book builds its code examples incrementally, introducing new concepts as it goes. It covers Hibernate's many, useful configuration and design options, breaking a complex subject into digestible pieces. With a gradual "crawl-walk-run" approach, the book teaches you what Hibernate is, what it can do, and how you can work with it effectively.

 

Table of Contents:

preface xv
acknowledgments xvii

about this book xviii
about the cover illustration xxiv

1 Why Hibernate?
Understanding object persistence
Identity - Inheritance - Associations - Object/relational mapping
Using direct JDBC
Example application - Retrieving object graphs using JDBC - Persisting object graphs to a relational model - Deleting object graphs - Querying object graphs
Persistence with Hibernate
Simplicity and flexibility - Completeness - Performance
Summary
2 Installing and building projects with Ant
Getting a Hibernate distribution
Installing Ant - Getting Ant - Extracting and installing Ant
Setting up a database
Getting MySQL - Testing MySQL - MySQL drivers
Setting up a project
Defining directories - Ant 101 - Running Ant
Habits of highly effective build files
Connecting Hibernate - Reusable build files - Expanding your horizons
Summary
3 Hibernate basics
Configuring Hibernate
Basic configuration
Creating mapping definitions
IDs and generators - Properties - Many-to-one element - Proxies - Collections - Cascades - Fetching associated objects
Building the SessionFactory
Configuring the SessionFactory
Persisting objects
Retrieving objects
The Session cache
Advanced configuration
Connection pools - Transactions - Cache providers
Inheritance
Table per class hierarchy - Table per subclass
Summary
4 Associations and components
Associations
Many-to-one relationships, in depth - The central configuration file - Defining sample data
Building tables with Ant and SchemaExport
Logging with log4j and Commons Logging - Running SchemaExport - Loading the Events - Refactoring - Finding Events - Cascades
Components
What's in a component? - Mapping a component - Why use a component?
Summary
5 Collections and custom types
Persisting collections and arrays
Using interfaces - Mapping persistent collections - Collection types - Lazy collections - Sorted collections - Bidirectional associations - Cascading collections
Implementing custom types
UserTypes - Implementing CompositeUserTypes
Summary
6 Querying persistent objects
Using HQL
session.find(…) - The Query interface - Outer joins and HQL - Show SQL
Query substitutions - Query parser
Querying objects with HQL
The FROM clause - Joins - Selects - Using functions - HQL properties - Using expressions
Criteria queries
Stored procedures
Hibern8IDE
Summary
7 Organizing with Spring and data access objects
The ubiquitous DAO pattern
Keeping the HQL together
Analyzing the DAO
Boilerplate code - Potential duplication - Detached objects only
The Layer Supertype pattern
Creating an AbstractDao
The Spring Framework
What's in a template? - Beans and their factories
Summary
8 Web frameworks: WebWork, Struts, and Tapestry
Defining the application
A quick overview of MVC
Service Layer pattern
Decoupling Hibernate from the web layer
Working with detached objects - Session scope - Accessing the Session from the Controller - Accessing the Session from the Service layer
WebWork
WebWork fundamentals - Creating controllers
Struts
Struts fundamentals - Building Struts Actions
Tapestry
Getting started - Tapestry fundamentals - HTML views - Page controller - Page specification - web.xml
Hibernate in the view layer
Summary
9 Hibernating with XDoclet
Essential XDoclet
JavaDoc basics - XDoclet: Building your own tags - Installing XDoclet - Configuring Ant
Making single objects persistent
The @hibernate.class tag - The @hibernate.id tag - The @hibernate.property tag - The @hibernate.column tag
Basic relationships
The @hibernate.many-to-one tag - The @hibernate.component tag
Building collections
One-to-many: a kicking set of Speakers - The @hibernate.set tag - The @hibernate.collection-key - The @hibernate.collection-one-to-many tag
Going where no XDoclet has gone before
Merge points - Property substitution
Generating the hibernate.cfg.xml file
Summary
10 Unit testing with JUnit and DBUnit
Introduction to unit testing
Automate those tests - Assertions - Expect failures
JUnit
Test-infecting your build file - Polishing off the build file
Testing the persistence layer
What do we want to test? - Testing basic persistence - Testing queries - General database testing tips 331
Testing with DBUnit
Loading test data - ProjectDatabaseTestCase
Summary
11 What's new in Hibernate 3
Filters
Mapping improvements
Multiple table mapping - Discriminator formulas - Union subclasses - Property references
Dynamic classes
Annotations
Stored procedures and SQL
Persistence events
Lazy properties
Summary


Appendix: The complete Hibernate mapping catalog
Index