Hibernate in Action View Larger Image | Christian Bauer, Gavin King Manning Publications, Paperback, Published August 2004, 408 pages, ISBN 193239415X | List Price: $44.95 Our Price: $27.95 You Save: $17.00 (38% Off)
| | | Availability: Out-Of-Stock |
Customer Reviews: 2 Average Customer Rating:      Write a Review and tell the world about this title! People who purchase this book frequently purchase: - Professional Java Development with the Spring Framework; Rod Johnson, et al, $24.95, 38% Off!
- Pro Spring; Rob Harrop, et al, $30.95, 38% Off!
- Expert One-on-One J2EE Development without EJB; Rod Johnson, et al, $24.95, 38% Off!
- Hibernate: A Developer's Notebook; James Elliott, $15.95, 36% Off!
Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:
Hibernate practically exploded on the Java scene. Why is this open-source tool
so popular? Because it automates a tedious task: persisting your Java objects
to a relational database. The inevitable mismatch between your object-oriented
code and the relational database requires you to write code that maps one to the
other. This code is often complex, tedious and costly to develop. Hibernate does
the mapping for you.
Not only that, Hibernate makes it easy. Positioned as a layer between your
application and your database, Hibernate takes care of loading and saving of
objects. Hibernate applications are cheaper, more portable, and more resilient
to change. And they perform better than anything you are likely to develop yourself.
Hibernate in Action carefully explains the concepts you need, then gets you
going. It builds on a single example to show you how to use Hibernate in practice,
how to deal with concurrency and transactions, how to efficiently retrieve objects
and use caching.
The authors created Hibernate and they field questions from the Hibernate community
every daythey know how to make Hibernate sing. Knowledge and insight seep
out of every pore of this book.
What's Inside
- ORM concepts
- Getting started
- Many real-world tasks
- The Hibernate application development processes
Preface
"Just because it is possible to push twigs along the ground with one's
nose does not necessarily mean that that is the best way to collect firewood."
-Anthony Berglas
Today, many software developers work with Enterprise Information Systems (EIS).
This kind of application creates, manages, and stores structured information
and shares this information between many users in multiple physical locations.
The storage of EIS data involves massive usage of SQL-based database management
systems. Every company we've met during our careers uses at least one SQL database;
most are completely dependent on relational database technology at the core
of their business.
In the past five years, broad adoption of the Java programming language has
brought about the ascendancy of the object-oriented paradigm for software development.
Developers are now sold on the benefits of object orientation. However, the
vast majority of businesses are also tied to long-term investments in expensive
relational database systems. Not only are particular vendor products entrenched,
but existing legacy data must be made available to (and via) the shiny new object-oriented
web applications.
However, the tabular representation of data in a relational system is fundamentally
different than the networks of objects used in object-oriented Java applications.
This difference has led to the so-called object/relational paradigm mismatch.
Traditionally, the importance and cost of this mismatch have been underestimated,
and tools for solving the mismatch have been insufficient. Meanwhile, Java developers
blame relational technology for the mismatch; data professionals blame object
technology.
Object/relational mapping (ORM) is the name given to automated solutions to
the mismatch problem. For developers weary of tedious data access code, the
good news is that ORM has come of age. Applications built with ORM middleware
can be expected to be cheaper, more performant, less vendor-specific, and more
able to cope with changes to the internal object or underlying SQL schema. The
astonishing thing is that these benefits are now available to Java developers
for free.
Gavin King began developing Hibernate in late 2001 when he found that the popular
persistence solution at the time-CMP Entity Beans-didn't scale to nontrivial
applications with complex data models. Hibernate began life as an independent,
noncommercial open source project.
The Hibernate team (including the authors) has learned ORM the hard way-that
is, by listening to user requests and implementing what was needed to satisfy
those requests. The result, Hibernate, is a practical solution, emphasizing
developer productivity and technical leadership. Hibernate has been used by
tens of thousands of users and in many thousands of production applications.
When the demands on their time became overwhelming, the Hibernate team concluded
that the future success of the project (and Gavin's continued sanity) demanded
professional developers dedicated full-time to Hibernate. Hibernate joined jboss.org
in late 2003 and now has a commercial aspect; you can purchase commercial support
and training from JBoss Inc. But commercial training shouldn't be the only way
to learn about Hibernate.
It's obvious that many, perhaps even most, Java projects benefit from the use
of an ORM solution like Hibernate-although this wasn't obvious a couple of years
ago! As ORM technology becomes increasingly mainstream, product documentation
such as Hibernate's free user manual is no longer sufficient. We realized that
the Hibernate community and new Hibernate users needed a full-length book, not
only to learn about developing software with Hibernate, but also to understand
and appreciate the object/relational mismatch and the motivations behind Hibernate's
design.
The book you're holding was an enormous effort that occupied most of our spare
time for more than a year. It was also the source of many heated disputes and
learning experiences. We hope this book is an excellent guide to Hibernate (or,
"the Hibernate bible," as one of our reviewers put it) and also the
first comprehensive documentation of the object/relational mismatch and ORM
in general. We hope you find it helpful and enjoy working with Hibernate.
Table of Contents
foreword
preface
acknowledgments
about this book
about Hibernate3 and EJB 3
author online
about the title and cover
1 Understanding object/relational persistence
What is persistence?
Relational databases - Understanding SQL - Using SQL in Java - Persistence
in object-oriented applications
The paradigm mismatch
The problem of granularity - The problem of subtypes - The problem of
identity - Problems relating to associations - The problem of object graph
navigation - The cost of the mismatch
Persistence layers and alternatives
Layered architecture - Hand-coding a persistence layer with SQL/JDBC -
Using serialization - Considering EJB entity beans - Object-oriented database
systems - Other options
Object/relational mapping
What is ORM? - Generic ORM problems - Why ORM?
Summary
2 Introducing and integrating Hibernate
"Hello World" with Hibernate
Understanding the architecture
The core interfaces - Callback interfaces - Types - Extension interfaces
Basic configuration
Creating a SessionFactory - Configuration in non-managed environments
- Configuration in managed environments
Advanced configuration settings
Using XML-based configuration - JNDI-bound SessionFactory - Logging -
Java Management Extensions (JMX)
Summary
3 Mapping persistent classes
The CaveatEmptor application
Analyzing the business domain - The CaveatEmptor domain model
Implementing the domain model
Addressing leakage of concerns - Transparent and automated persistence
- Writing POJOs - Implementing POJO associations - Adding logic to accessor
methods
Defining the mapping metadata
Metadata in XML - Basic property and class mappings - Attribute-oriented
programming - Manipulating metadata at runtime
Understanding object identity
Identity versus equality - Database identity with Hibernate - Choosing
primary keys
Fine-grained object models
Entity and value types - Using components
Mapping class inheritance
Table per concrete class - Table per class hierarchy - Table per subclass
- Choosing a strategy
Introducing associations
Managed associations? - Multiplicity - The simplest possible association
- Making the association bidirectional - A parent/child relationship
Summary
4 Working with persistent objects
The persistence lifecycle
Transient objects - Persistent objects - Detached objects - The scope
of object identity - Outside the identity scope - Implementing equals()
and hashCode()
The persistence manager
Making an object persistent - Updating the persistent state of a detached
instance - Retrieving a persistent object - Updating a persistent object
- Making a persistent object transient - Making a detached object transient
Using transitive persistence in Hibernate
Persistence by reachability - Cascading persistence with Hibernate - Managing
auction categories - Distinguishing between transient and detached instances
Retrieving objects
Retrieving objects by identifier - Introducing HQL - Query by criteria
- Query by example - Fetching strategies - Selecting a fetching strategy
in mappings - Tuning object retrieval
Summary
5 Transactions, concurrency, and caching
Transactions, concurrency, and caching
Understanding database transactions
JDBC and JTA transactions - The Hibernate Transaction API - Flushing the
Session - Understanding isolation levels - Choosing an isolation level -
Setting an isolation level - Using pessimistic locking
Working with application transactions
Using managed versioning - Granularity of a Session - Other ways to implement
optimistic locking
Caching theory and practice
Caching strategies and scopes - The Hibernate cache architecture - Caching
in practice
Summary
6 Advanced mapping concepts
Understanding the Hibernate type system
Built-in mapping types - Using mapping types
Mapping collections of value types
Sets, bags, lists, and maps
Mapping entity associations
One-to-one associations - Many-to-many associations
Mapping polymorphic associations
Polymorphic many-to-one associations - Polymorphic collections - Polymorphic
associations and table-per- concrete-class
Summary
7 Retrieving objects efficiently
Executing queries
The query interfaces - Binding parameters - Using named queries
Basic queries for objects
The simplest query - Using aliases - Polymorphic queries - Restriction
- Comparison operators - String matching - Logical operators - Ordering
query results
Joining associations
Hibernate join options - Fetching associations 260 - Using aliases with
joins 262 - Using implicit joins 265 - Theta-style joins 267 - Comparing
identifiers
Writing report queries - Projection - Using aggregation - Grouping
Restricting groups with having - Improving performance with report queries
Advanced query techniques
Dynamic queries - Collection filters - Subqueries - Native SQL queries
Optimizing object retrieval
Solving the n+1 selects problem - Using iterate() queries - Caching queries
Summary
8 Writing Hibernate applications
Designing layered applications
Using Hibernate in a servlet engine - Using Hibernate in an EJB container
Implementing application transactions
Approving a new auction - Doing it the hard way - Using detached persistent
objects - Using a long session - Choosing an approach to application transactions
Handling special kinds of data
Legacy schemas and composite keys - Audit logging
Summary
9 Using the toolset
Development processes
Top down - Bottom up - Middle out (metadata oriented) - Meet in the middle
- Roundtripping
Automatic schema generation
Preparing the mapping metadata - Creating the schema - Updating the schema
Generating POJO code
Adding meta-attributes - Generating finders - Configuring hbm2java - Running
hbm2java
Existing schemas and Middlegen
Starting Middlegen - Restricting tables and relationships - Customizing
the metadata generation - Generating hbm2java and XDoclet metadata
XDoclet
Setting value type attributes - Mapping entity associations - Running XDoclet
Summary
appendix A: SQL fundamentals
appendix B: ORM implementation strategies
Properties or fields?
Dirty-checking strategies
appendix C: Back in the real world
The strange copy
The more the better
We don?t need primary keys
Time isn?t linear
Dynamically unsafe
To synchronize or not?
Really fat client
Resuming Hibernate
references
index
About the Authors
A member of the core Hibernate developer team, Christian Bauer
maintains the Hibernate documentation and website. He is a senior software engineer
in Frankfurt, Germany. Gavin King is the Hibernate founder and
principal developer. He is a J2EE consultant based in Melbourne, Australia.
Reviews
"This is another one of those books that shouldn't be torn into until
you have some idea of what you are looking for. Hibernate, the software system
that is the heart of the book is (in my mind at least) the glue that goes between
Java and a SQL database. You should have some experience with both Java and
SQL to begin to understand the power that Hibernate brings to the table.
Once you have that down, then this book becomes well worth the cost. It's true
that Open Source projects, such as Hibernate, have on-line documentation. But
that documentation is written differently than a book. It is aimed at a different
audience, and often doesn't have the consistent front to back approach that
a well thought out book has.
This book is an excellent example. While the on-line documentation is good,
(Mr. Bauer, one of the authors is in charge of the on-line documentation) the
book is better. It begins with a description of what you are trying to do (often
left out in computer books) and leads you on in a consistent manner through
the entire Hibernate system. Excellent Book!"
-- Books-on-Line
"Having used Hibernate for about a year before any book was available,
I relied mainly on the documentation available at the web site. But this book
from none others than the lead developer and the lead documenter is a great
introduction and reference documentation to using Hibernate. The book is organized
in such a way that the concepts are explained in progressive order from very
simple to more complex, and the authors take good care of explaining every detail
with good examples, but most importantly with the reasoning behind what the
problem are we are trying to solve and why Hibernate chose to implement the
solution in this or that way.
"The book not only gets you up to speed with Hibernate and its features
(which the documentation does quite well). It also introduces you to the right
way of developing and tuning an industrial-quality Hibernate application."
-- Slashdot.org
"A compact (408 pages), focused, no nonsense read and an essential resource
for anyone venturing into the ORM landscape. The first three chapters of this
book alone are indespensible for developers that want to quickly build an application
leveraging Hibernate, but more importantly really want to understand Hibernate
concepts, framework, methodology and the reasons that shaped the framework design.
The remaining chapters continue the comprehensive overview of Hibernate that
include how to map to and persist objects, inheritance, transactions, concurrency,
caching, retrieving objects efficiently using HQL, configuring Hibernate for
managed and unmanaged environments, and the Hibernate Toolset that can be leveraged
for several different development scenarios."
-- Columbia Java Users Group
"Hibernate In Action is an effective user's manual for the open-source
Java tool of Hibernate, which has exploded in popularity due to its automation
of a tedious task: persisting Java objects to a relational database, a task
made laborious by the necessity of having to write code that maps one's object-oriented
code to a relational database or vice-versa. Hibernate In Action explains the
basic workings of Hibernate with examples, detailed instructions for using it,
how to deal with concurrency and transactions, efficiently retrieving objects,
caching, and much more. Diagrams and sample code further elucidate this no-nonsense,
easy-to-follow guide highly recommended for anyone tapping into the streamlined
power of Hibernate."
-- Midwest Book Review
"Not only gets you up to speed with Hibernate and its features...It also
introduces you to the right way of developing and tuning an industrial-quality
Hibernate application. ...albeit very technical, it reads astonishingly easy
...unfortunately very rare nowadays ...[an] excellent piece of work..."
-- Adrian Spinei at JavaLobby.com
"The authors show their knowledge of relational databases and the paradigm
of mapping this world with the object-oriented world of Java. This is why the
book is so good at explaining Hibernate in the context of solving or providing
a solution to the very complex problem of object/relational mapping.
There are other books that came out around the same time as this book and others
that are coming in the following months, but this book is a very complete introduction
to using Hibernate and its architecture and will become an essential reading
for all developers interested in learning Hibernate."
-- Denver JUG
Customer Reviews
Customer Reviews: 2 Average Customer Rating:      Mar 16, 2006     Chris from Kentucky, USA Dissapointing It provides excellent coverage of the design problems that hibernate helps alleviate and to cause. It covers many aspects of hibernate. What it does not do is get you "In Action". I didn't find one piece of useable code in this book. It all has come from the hibernate website. I was hoping for a jumpstart in getting some code written and what I got was theory. The content wasn't bad in and of itself it just doesn't match its title. "Hibernate in Theory", "Hibernate In Overview" or maybe "An argument for Hibernate".
Oct 1, 2004     Ray Clough (ray@allthisisthat.com) from California This book is terrific I've learned more from this book than from almost any other 3 books I've read. Aside from learning about Hibernate, it gives a terrific overview of the problems involved in writing a persistence layer, and discusses the Object-Relational mismatch very clearly. Since preliminary reports are that EJB 3.0 is going to be pretty similar to Hibernate, it looks like learning Hibernate now is an excellent investment in time and effort. Of all the products I've seen, studied, or used, Hibernate is the one I wish I'd created, and this book shows clearly how to use it.
|