没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Ottinger
Minter
Linwood
Shelve in
Programming Languages/Java
User level:
Beginning–Intermediate
www.apress.com
SOURCE CODE ONLINE
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Beginning Hibernate
Beginning Hibernate, Third Edition is ideal if you’re experienced in Java with
databases (the traditional, or “connected,” approach), but new to open-source,
lightweight Hibernate, a leading object-relational mapping and database-oriented
application development framework.
This book packs in information about the release of the Hibernate 4.x persistence
layer and provides a clear introduction to the current standard for object-relational
persistence in Java. And since the book keeps its focus on Hibernate without wasting
time on nonessential third-party tools, you’ll be able to immediately start building
transaction-based engines and applications.
Experienced authors Joseph Ottinger with Dave Minter and Jeff Linwood provide
more in-depth examples than any other book for Hibernate beginners. The authors also
present material in a lively, example-based manner—not a dry, theoretical, hard-to-read
fashion.
What You’ll Learn:
• How to build enterprise Java-based transaction-type applications
that access complex data with Hibernate
• How to work with Hibernate 4
• Where to integrate into the persistence life cycle
• How to map using annotations, Hibernate XML files, and more
• How to search and query with the new version of Hibernate
• How to integrate with MongoDB using NoSQL
THIRD
EDITION
RELATED
9781430 265177
54999
ISBN 978-1-4302-6517-7
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
v
Contents at a Glance
About the Authors ��������������������������������������������������������������������������������������������������������������� xv
About the Technical Reviewer ������������������������������������������������������������������������������������������ xvii
Acknowledgments ������������������������������������������������������������������������������������������������������������� xix
Introduction ����������������������������������������������������������������������������������������������������������������������� xxi
Chapter 1: An Introduction to Hibernate 4�2 ■ ����������������������������������������������������������������������1
Chapter 2: Integrating and Configuring Hibernate ■ ������������������������������������������������������������9
Chapter 3: Building a Simple Application ■ ������������������������������������������������������������������������19
Chapter 4: The Persistence Life Cycle ■ �����������������������������������������������������������������������������41
Chapter 5: An Overview of Mapping ■ ��������������������������������������������������������������������������������69
Chapter 6: Mapping with Annotations ■ �����������������������������������������������������������������������������81
Chapter 7: JPA Integration and Lifecycle Events ■ �����������������������������������������������������������115
Chapter 8: Using the Session ■ �����������������������������������������������������������������������������������������135
Chapter 9: Searches and Queries ■ ����������������������������������������������������������������������������������149
Chapter 10: Advanced Queries Using Criteria ■ ���������������������������������������������������������������165
Chapter 11: Filtering the Results of Searches ■ ���������������������������������������������������������������175
Chapter 12: Leaving the Relational Database Behind: NoSQL ■ ���������������������������������������183
Appendix: More Advanced Features ■ ������������������������������������������������������������������������������195
Index ���������������������������������������������������������������������������������������������������������������������������������205
xxi
Introduction
Hibernate is an amazing piece of software. With a little experience and the power of annotations, you can build a
complex, database-backed system with disturbing ease. Once you have built a system using Hibernate, you will never
want to go back to the traditional approaches.
While Hibernate is incredibly powerful, it presents a steep learning curve when you rst encounter it—steep
learning curves are actually a good thing because they impart profound insight once you have scaled them. Yet
gaining that insight takes some perseverance and assistance.
Our aim in this book is to help you scale that learning curve by presenting you with the minimal requirements
of a discrete Hibernate application, explaining the basis of those requirements, and walking you through an example
application that is built using them. We then provide additional material to be digested once the fundamentals are
rmly understood. roughout, we provide examples rather than relying on pure discourse. We hope that you will
continue to nd this book useful as a reference text long after you have become an expert on the subject.
Who This Book Is For
is book assumes a good understanding of Java fundamentals and some familiarity with database programming
using the Java Database Connectivity (JDBC) API. We don’t expect you to know anything about Hibernate—but if
you buy this book, it will probably be because you have had some exposure to the painful process of building a large
database-based system.
All of our examples use open-source software—primarily the Hibernate API itself—so you will not need to
purchase any software to get started with Hibernate development. is book is not an academic text. Our focus is,
instead, on providing extensive examples and taking a pragmatic approach to the technology that it covers.
To true newcomers to the Hibernate API, we recommend that you read at least the rst three chapters in order
before diving into the juicy subjects of later chapters. Very experienced developers or those with experience with
tools similar to Hibernate will want to skim the latter half of the book for interesting chapters. Readers familiar with
Hibernate will want to turn to the appendix for discussion of more arcane topics.
How This Book Is Structured
is book is informally divided into three parts. Chapters 1 through 8 describe the fundamentals of Hibernate,
including conguration, the creation of mapping les, and the basic APIs. Chapters 9 through 11 describe the use of
queries, criteria, and lters to access the persistent information in more sophisticated ways. Chapter 12 addresses the
use of Hibernate to talk to nonrelational data stores, providing an easy “on ramp” to NoSQL.
Finally, the appendixes discuss features that you will use less often or that are peripheral to the core Hibernate
functionality. e following list describes more fully the contents of each chapter:
Chapter 1 outlines the purpose of persistence tools and presents excerpts from a simple example application to
show how Hibernate can be applied. It also introduces core terminology and concepts.
Chapter 2 discusses the fundamentals of conguring a Hibernate application. It presents the basic architecture of
Hibernate and discusses how a Hibernate application is integrated into an application.
■ IntroduCtIon
xxii
Chapter 3 presents an example application, walking you through the complete process of creating and running
the application. It then looks at a slightly more complex example and introduces the notion of generating the database
schema directly from Hibernate annotations.
Chapter 4 covers the Hibernate lifecycle in depth. It discusses the lifecycle in the context of the methods available
on the core interfaces. It also introduces key terminology and discusses the need for cascading and lazy loading.
Chapter 5 explains why mapping information must be retained by Hibernate and demonstrates the various types
of associations that can be represented by a relational database. It briey discusses the other information that can be
maintained within a Hibernate mapping.
Chapter 6 explains how Hibernate lets you use the annotations to represent mapping information. It provides
detailed examples for the most important annotations, and discusses the distinctions between the standard JPA 2
annotations and the proprietary Hibernate ones.
Chapter 7 explains some of the uses of the Java Persistence API (as opposed to the Hibernate-native API), as well
as the lifecycle and validation of persisted objects.
Chapter 8 revisits the Hibernate Session object in detail, explaining the various methods that it provides.
e chapter also discusses the use of transactions, locking, and caching, as well as how to use Hibernate in a
multithreaded environment.
Chapter 9 discusses how Hibernate can be used to make sophisticated queries against the underlying relational
database using the built-in Hibernate Query Language (HQL).
Chapter 10 introduces the Criteria API, which is a programmatic analog of the query language discussed
in Chapter 9.
Chapter 11 discusses how the Filter API can be used to restrict the results of the queries introduced in
Chapters 9 and 10.
Chapter 12 introduces Hibernate OGM, which maps objects to non-relational data stores like Innispan and
Mongodb, among others. It shows some of the uses of Hibernate Search to provide a common search facility for
NoSQL, as well as oering full text query support.
Appendix presents a large number of peripheral features that do not warrant more extensive coverage in a
beginner-level text. e appendix discusses the basics, with examples, of the support for versioning and optimistic
locking, and some of the obscure limitations of Hibernate and various ways that these can be worked around. It also
discusses the use of events and interceptors.
Downloading the Code
e source code for this book is available to readers from www.apress.com, in the Source Code/Download section.
Please feel free to visit the Apress web site and download all the code from there.
Contacting the Authors
We welcome feedback from our readers. If you have any queries or suggestions about this book, or technical questions
about Hibernate, or if you just want to share a really good joke, you can email Joseph Ottinger at joeo@enigmastation.com,
Dave Minter at dave@paperstack.com, and Je Linwood at jlinwood@gmail.com.
剩余222页未读,继续阅读
资源评论
- wzbyytm2014-07-03可供快速学习Hibernate4.x
- pipiluca2015-05-01最新版的,好东西啊
- oanda662014-05-09Very good book. English version. Very clear. Thank you for sharing!
- mianbao54812014-05-16不错,感谢楼主
- CrCat2015-04-10新书,有很多干货!感谢LZ!
麻团
- 粉丝: 5
- 资源: 83
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功