free ebooks
 Home Computers & InternetProgramming > Java  
Hibernate in Action

Hibernate in Action

Summary of TOC/Sections

Chapter 1: Understanding object/relational persistence

The first chapter explains the concept of object persistence and why ORM is important. The authors have done an outstanding job in explaining the benefits of ORM and Hibernate. This chapter also explains the alternative solutions for persistence like SQL/JDBC, EJB entity beans and discusses the pros and cons of each solution. It tells about the history, the features and the difficulties to build systems using these approaches and gives the reader a very good introduction to persistence.

Chapter 2: Introducing and integrating Hibernate

In the second chapter the Authors give us a quick trip to Hibernate giving a simple “Hello World” example and a high-level view of the API, the 5 core Interfaces which will be used in every Hibernate application. It also gives an overview of the Basic and Advanced configuration settings. I liked the Logging configuration setting which really helped me in debugging the code when I was having difficulty inserting into a table. The authors warn us though that we should not be doing this in the Production Environment.

Chapter 3: Mapping persistent classes

Chapter 3 focuses mainly on how to implement the persistent classes in the Domain Model and the best practices to follow while doing so. It describes the best practices for writing POJOs and how POJOs are Hibernate compatible without any changes with a simple User class for the User entity, how properties are used to express associations between POJO classes. It shows how to use the Metadata in XML to define the mapping for the persistent classes and their associations. I liked the explanation given by the authors for understanding object identity, the preferred primary key generation and the most useful options in a table.

Chapter 4: Working with persistent objects

This chapter explains about the persistence lifecycle, the three types of object states: transient, persistent and detached, how an object can transition from one state to another. It gives a very good explanation of the persistence manager API, the different interfaces, and the central interface in Hibernate being Session and how to use it. It also provides an introduction about how Objects can be retrieved by using one of the following: HQL for retrieving objects, by identifier, using query by criteria API, using native SQL queries, navigating the object graph. At the end of this chapter is detailed discussion and recommendations about the various fetching strategies.

Chapter 5: Transactions, concurrency and caching

Chapter 5 covers topics on Transactions, Concurrency and Caching. It begins by explaining what is a Transaction, what is an ACID behavior, understanding Database transactions as well as JDBC and JTA transactions. If you have already done a lot of work on these you can easily skip these sections. But the next few sections explain how Transaction management is available through the Hibernate API. Next they discuss about the isolation levels, issues, how you can choose the one that suits your application and also locking.

The remaining sections are about the fundamentals of Caching and how to use caching effectively in Hibernate applications. It explains in detail about the Hibernate Cache architecture, the first level and pluggable second-level cache architecture; how to optimize the same, the various cache providers you can use with Hibernate as a plug-in. It also continues with setting up the cache providers for the second level cache in the CaveatEmptor application. The authors have chosen the EHCache as the second-level cache here. Next they show how to setup JBossCache for the same application for a small cluster of two nodes. The caching architecture and how to use it with your application is very well explained.

Chapter 6: Advanced mapping concepts

This chapter covers Advanced mapping concepts. It starts by explaining the Hibernate type system of entities, value types and mapping types. The next section explains about the Built-in mapping types, using mapping types in the Hibernate mapping document. It gives detailed explanation custom mapping types, collection mappings like set, bag, list etc, one-one, one-to-many and many-to-many associations between entities and in practice also recommend against the overuse of many-to-many relationships.

Chapter 7: Retrieving objects efficiently

At this point the reader would have made a decision to use Hibernate in their application and if so this is the chapter which would be useful as a reference guide for topics like the Hibernate query, HQL, criteria and native SQL queries. This chapter has code examples for the above. The section which explains the various Hibernate Join options will definitely be read over and over again as a reference. It also covers advanced query techniques which explain Dynamic queries, Collection filters, sub queries and Native SQL. The last section covers Optimizing object retrieval for n+1 selects problem, using iterate queries and Caching queries.

Chapter 8: Writing Hibernate applications

This chapter discusses how to design layered applications, and shows how to separate Hibernate related code from the Business and presentation layers. It shows how to use Hibernate in a Servlet engine and then in an EJB environment. The next section explains thread-local session pattern and how to execute the same and creating smart domain models using Data Access Objects. Then comes the Interesting discussion about data transfer objects. The authors very well explain how to use the Session Façade Pattern and EJB command pattern in an EJB Container. It explains the usage of detached objects while working with long running application transactions. The Later sections show how to work with the legacy data schemas, how to map composite keys, triggers and use them in application code. Finally, the chapter ends with a brief discussion about Audit Logging and how we could implement the same using the Hibernate Interceptor

Chapter 9: Using the toolset

Using the Toolset covers, the various tools provided by Hibernate to support the development processes and the different scenarios like Top down using XDoclet, Bottom up using Middlegen and so on. Knowing about these tools is extremely important to speed up the process of development. All the available tools are mentioned in detail. I worked out all the samples by hand as I went through each chapter knowing very well that there were tools to generate most of these. This chapter really helps in knowing all the toolsets and where they can be used.

Appendix A: This is a short section which provides the reader with a summary of SQL fundamentals.

Appendix B: This provides some insight into Hibernate internals, the detection of modified object state for dirty checking.

Appendix C: The authors try to answer some peculiar questions.

Accuracy/Applicability of content

As many people have said, the book comes straight from the source; the authors have done an excellent job in explaining each and every concept. I will definitely give 5 stars since I am so very convinced to use Hibernate in my application and am so glad would be using all the best practices and design patterns which are explained so systematically by the Authors.

 Additional Info
 
 No. 450
 Posted on 9 June, 2006
 
 
 
Bookmark This Page
Facebook MySpace Twitter Digg stumbleupon friendfeed Delicious

Share
Email
Google

Link to us from your website or blog by using the code below in your html
   
@2008 ebooklobby privacy policy email: info [at] goaheadweb.co.uk