Hibernate Quickly
暫譯: 快速掌握 Hibernate

Patrick Peak, Nick Heudecker

  • 出版商: Manning
  • 出版日期: 2005-08-16
  • 售價: $1,680
  • 貴賓價: 9.5$1,596
  • 語言: 英文
  • 頁數: 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

商品描述(中文翻譯)

**描述:**
「我強烈推薦這本書。」
- Christopher Haupt,Adobe Systems Inc. 高級工程經理

「如果你想快速學習 Hibernate,這本書一步一步地教你。」
- Sang Shin,Sun Microsystems Java 技術架構師

Hibernate 作為應用程式與資料庫之間的一層,是一個強大的物件/關聯持久性和查詢服務,專為 Java 設計。它自動化了一項繁瑣的任務:手動橋接物件導向程式碼與關聯資料庫之間的差距。《Hibernate Quickly》提供了你開始使用 Hibernate 所需的一切。

本書專注於你 80% 時間所需的 20% 知識。節省下來的頁面用來介紹 Hibernate 的「生態系統」:Hibernate 如何與其他常見的開發工具和框架(如 XDoclet、Struts、Webwork、Spring 和 Tapestry)協同工作。

本書逐步構建其程式碼範例,隨著進展引入新概念。它涵蓋了 Hibernate 許多有用的配置和設計選項,將複雜的主題分解為易於消化的部分。透過逐步的「爬行-走路-奔跑」方法,本書教你什麼是 Hibernate、它能做什麼,以及如何有效地使用它。

**目錄:**
- 前言 xv
- 感謝 xvii
- 關於本書 xviii
- 封面插圖說明 xxiv

1. 為什麼選擇 Hibernate?
- 理解物件持久性
- 身份 - 繼承 - 關聯 - 物件/關聯映射
- 使用直接 JDBC
- 範例應用程式 - 使用 JDBC 檢索物件圖 - 將物件圖持久化到關聯模型 - 刪除物件圖 - 查詢物件圖
- 使用 Hibernate 的持久性
- 簡單性和靈活性 - 完整性 - 性能
- 總結

2. 使用 Ant 安裝和構建專案
- 獲取 Hibernate 發行版
- 安裝 Ant - 獲取 Ant - 解壓和安裝 Ant
- 設置資料庫
- 獲取 MySQL - 測試 MySQL - MySQL 驅動程式
- 設置專案
- 定義目錄 - Ant 101 - 執行 Ant
- 高效能構建檔案的習慣
- 連接 Hibernate - 可重用的構建檔案 - 擴展你的視野
- 總結

3. Hibernate 基礎
- 配置 Hibernate
- 基本配置
- 創建映射定義
- ID 和生成器 - 屬性 - 多對一元素 - 代理 - 集合 - 傳播 - 獲取關聯物件
- 建立 SessionFactory
- 配置 SessionFactory
- 持久化物件
- 檢索物件
- Session 快取
- 高級配置
- 連接池 - 交易 - 快取提供者
- 繼承
- 每個類別層次的表 - 每個子類的表
- 總結

4. 關聯和組件
- 關聯
- 多對一關係,深入探討 - 中央配置檔案 - 定義範例數據
- 使用 Ant 和 SchemaExport 建立表
- 使用 log4j 和 Commons Logging 記錄 - 執行 SchemaExport - 載入事件 - 重構 - 查找事件 - 傳播
- 組件
- 組件中包含什麼? - 映射一個組件 - 為什麼使用組件?
- 總結

5. 集合和自定義類型
- 持久化集合和數組
- 使用介面 - 映射持久化集合 - 集合類型 - 延遲集合 - 排序集合 - 雙向關聯 - 傳播集合
- 實現自定義類型
- UserTypes - 實現 CompositeUserTypes
- 總結

6. 查詢持久化物件
- 使用 HQL
- session.find(…) - 查詢介面 - 外部連接和 HQL - 顯示 SQL
- 查詢替代 - 查詢解析器
- 使用 HQL 查詢物件
- FROM 子句 - 連接 - 選擇 - 使用函數 - HQL 屬性 - 使用表達式
- 條件查詢
- 儲存過程
- Hibern8IDE
- 總結

7. 使用 Spring 和資料存取物件進行組織
- 無處不在的 DAO 模式
- 保持 HQL 一致
- 分析 DAO
- 標準程式碼 - 潛在重複 - 僅限脫離物件
- 層超類型模式
- 創建 AbstractDao
- Spring 框架
- 模板中包含什麼? - Beans 及其工廠
- 總結

8. 網頁框架:WebWork、Struts 和 Tapestry
- 定義應用程式
- MVC 的快速概述
- 服務層模式
- 將 Hibernate 與網頁層解耦
- 使用脫離物件 - Session 範圍 - 從控制器訪問 Session - 從服務層訪問 Session
- WebWork
- WebWork 基礎 - 創建控制器
- Struts
- Struts 基礎 - 建立 Struts 行動
- Tapestry
- 開始使用 - Tapestry 基礎 - HTML 視圖 - 頁面控制器 - 頁面規範 - web.xml
- 在視圖層中的 Hibernate
- 總結

9. 使用 XDoclet 進行 Hibernate
- 必備的 XDoclet
- JavaDoc 基礎 - XDoclet:建立自己的標籤 - 安裝 XDoclet - 配置 Ant
- 使單一物件持久化
- @hibernate.class 標籤 - @hibernate.id 標籤 - @hibernate.property 標籤 - @hibernate.column 標籤
- 基本關係
- @hibernate.many-to-one 標籤 - @hibernate.component 標籤
- 建立集合
- 一對多:一組強大的揚聲器 - @hibernate.set 標籤 - @hibernate.collection-key - @hibernate.collection-one-to-many 標籤
- 前往 XDoclet 從未到達的地方
- 合併點 - 屬性替代
- 生成 hibernate.cfg.xml 檔案
- 總結

10. 使用 JUnit 和 DBUnit 進行單元測試
- 單元測試介紹
- 自動化測試 - 斷言 - 預期失敗
- JUnit
- 測試感染你的構建檔案 - 完善構建檔案
- 測試持久性層
- 我們想測試什麼? - 測試基本持久性 - 測試查詢 - 一般資料庫測試提示
- 使用 DBUnit 測試
- 載入測試數據 - ProjectDatabaseTestCase
- 總結

11. Hibernate 3 的新特性