Win Your Copy: Java Persistence with Hibernate
Buy it now
One Minute Bottom Line
Whether you are new to Hibernate and want to dive into your first project or are a Hibernate guru and need a reference manual to remind you of how to implement a conversation, this is the right book. The authors have really covered all the bases. Anything you want to know about Hibernate is in here.
I highly recommend this book to anyone needing to get started with Java and Hibernate!
This book is divided into 3 parts with 2 appendices.
Part 1: Getting Started With Hibernate and EJB 3.0
This is the foundation for understanding how Hibernate works. The most relevant part for me was selling me on "why Hibernate?" I've always been a "do it yourself SQL person". In chapter 1, I was sold. Forget ease of use. Forget performance and caching. The integration between Hibernate and EJB and the fact that JPA is becoming the standard was enough to make me take notice that this is a technology you cannot ignore if you are going to develop Java applications that use a relational database.
Chapter 2 helps you get going on your first project. Everything from creating the database to a preview of Hibernate annotations is covered.
Part 2: Mapping Concepts and Strategies
In an object-relational mapping solution you will soon find that how you map your objects in code is a lot of the challenge. While about 80% of the mappings that you do will be very simple, you will likely have some mappings that are more challenging and problematic.
Chapter 4 starts you out and delves into the simple to the advanced mapping topics you will need. This is a fantastic chapter and was probably the most useful one for me.
Chapter 6 covers mapping collections and is an essential foundation if you are going to be doing any sort of joins or other derived data sets in your mappings.
Chapter 7 goes into how those joins are accomplished in your mapping.
Chapter 8 covers what to do if you need to use an existing or legacy database. This is not just a "how do I use Hibernate with my existing schema" but it also explains some improvements that Hibernate can make to get more out of that legacy system. Very nice! Because we don't always get to start out with a clean slate!
Part 3: Conversation Object Processing
This was a rather new concept to me. I have always been used to managing transactions and session data myself. But the concept of a "conversation" was something that I have never considered until reading this section.
In chapter 10 transactions and concurrency are covered in dept. I was familiar with this part.
However, in chapter 11, the conversation is introduced. The conversation is more than just using session data. It can include several transactions and other user actions.
If you want a lesson in efficiency and how to manage large sets of data, then chapters 12 and 13 are for you. Dynamic data filtering and caching were the most useful and interesting to me and if you are going to work with large data sets, I highly recommend spending some time understanding the concepts given here.
The rest of this part of the book and appendix A are all about query language, querying and the API and how they are used. This is a proportionately large section in the book and rightfully so because understanding this is fundamental to understanding Hibernate. After all, Hibernate must, at some point, create a query that is native to the database it is used with. Debugging such a thing can be difficult if you are unfamiliar with query concepts.
There is also part in chapter 16 that covers unit testing Hibernate code. If there is a negative aspect of this book, this is it. I don't think enough emphasis was given to this topic. However, unit testing is a fairly domain specific thing and I'm not sure that it could (or should) be covered in too much depth. After getting to this point, you should take what you have learned about Hibernate and apply your own knowledge of unit testing.
Appendix A: SQL fundamentals
This appendix is just that: fundamentals. It gives you enough information to understand what SQL is and some fundamental concepts but is in no way meant to be (nor could it be) a comprehensive overview of SQL. If you want an in-depth study of SQL, grab a database like MySQL and the manual and get to it!
The book index is probably your best friend when it comes to reference information especially when you have an idea about an annotation that you want to use but can't quite remember where it was or how it was spelled, etc. I loved the index to this book! What a huge help!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)