Win Your Copy: Java Persistence with Hibernate
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! |
Review
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!
For more information about the author and this book click here.
Click here to see all 46 DZone Refcardz and cheat like a PRO!
- Login or register to post comments
- 4292 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)











Comments
pwwallace replied on Wed, 2009/03/25 - 11:33am
Bertrand GILLIS replied on Wed, 2009/03/25 - 11:53am
This is the BEST book for hibernate.
Better than hibernate in action and other books.
More real world illustrative examples will be greatly welcome.
dlopezleon replied on Wed, 2009/03/25 - 12:04pm
Álvaro Martínez replied on Wed, 2009/03/25 - 12:13pm
There is no alternative to Hibernate for "usual" projects these days. I don't even know what I'm doing using JPA in top of it since I won't use any other ORM solution (but I guess it's the right thing to do).
I'm currently using Hibernate with Scala. It's usually painless, but Scala doesn't currently support nested annotations, and that is a problem at least with JPA. All I have to do is to define these complexmappings in a hbm.xml file. Anyway, this problem should be fixed in Scala 2.8.0.
dzoneCody replied on Wed, 2009/03/25 - 12:19pm
Giri Senji replied on Wed, 2009/03/25 - 12:23pm
dustmachine replied on Wed, 2009/03/25 - 12:32pm
tenshi replied on Wed, 2009/03/25 - 4:00pm
hantsy replied on Wed, 2009/03/25 - 9:18pm
I have used Hibernate in work for years. Most of the projects, I used MySQL as database and using custom JDBC DAO implementation as persistent layer , after using Hibernate, I do not care the database-specific feature and focus the business implementation. Hibernate hides the JDBC operation and SQL writing directly for client caller. It make the complex things become simple.
r_sudh replied on Wed, 2009/03/25 - 10:32pm
silhanek replied on Thu, 2009/03/26 - 2:27am
I build new big application over NetBeans Platform and I will use Hibernate to DB connection. I have some difficulties because I must wrap entity library and hibernate jars. It works as a prototype but it has not worked in application yet.
Searching I need use for client or contract retrieval and I want to care about my problem domain only.
Milos
Jeroen Wenting replied on Thu, 2009/03/26 - 2:50am
Better than hibernate in action and other books. "
It should be better, it replaces Hibernate in Action :)
Not currently working with Hibernate, but have in the past. This book helped me out in some tight spots. Would have liked a free eBook version to come with it though, similar to what APress does with some of their biggest tomes, as it's rather hefty to carry between home and office every day. For that reason alone I wouldn't mind another copy.
Girish Ahankari replied on Thu, 2009/03/26 - 3:34am
wesslan replied on Thu, 2009/03/26 - 4:24am
We use Hibernate for persistence at work all the time and it performs just great!
lsabin replied on Thu, 2009/03/26 - 5:39am
Todd Cosgrove replied on Thu, 2009/03/26 - 8:23am
gianfranco replied on Thu, 2009/03/26 - 8:31am
Thanks for the review.
In particular Chapter 8 raises my interest: not all projects are green-field and since introducing Hibernate is an option to consider some guidelines in doing so are always welcome.
Personally I would not have minded excluding Appendix A: SQL fundamentals from the book, I think someone picking up the book should think of Hibernate as the missing link between two worlds (db and code) and understand these two worlds a priori.
Andy Jefferson replied on Thu, 2009/03/26 - 8:48am
Alvaro Martinez said, "There is no alternative to Hibernate for "usual" projects these days."
Oh, there are plenty of alternatives; we aren't in the same situation as in 2002 - developers are spoilt for choice now. Many alternatives have more flexible licensing. Many are doing things that Hibernate doesn't approach. Many are faster. I'd encourage you to investigate further ...
--Andy DataNucleus
stan229 replied on Thu, 2009/03/26 - 8:54am
Used JPA with Hibernate implementation in my latest web application using GWT. It was interesting working with two models, one being JPA entities and the other being a stripped down GWT Bean. Would like to learn more about Hibernate and JPA
Álvaro Martínez replied on Thu, 2009/03/26 - 10:36am
aarkay007 replied on Thu, 2009/03/26 - 10:03am
kunal dabir replied on Fri, 2009/03/27 - 1:35pm
I've been using hibernate for last few projects and i must say it rocks. In the current project we are using hibernate to load entities in Map Mode. This is such a dynamic feature that one can complete an entire project without ever having to implement the domain models java classes. I'd love to see a bit more coverage on Map and DOM modes in this book (as this is more useful than authors considered it to be). In fact, some good frameworks can be built up using these modes to provide dynamic UIs (Or is something out there already built on this?).
mr_bungalow replied on Thu, 2009/03/26 - 1:31pm
dzb replied on Thu, 2009/03/26 - 2:05pm
paulszulc replied on Thu, 2009/03/26 - 3:04pm
THIS BOOK IS NOT GOOD!!!
or
... maybe it is?
I dont, know. I would have to rread it, to tell you.
jkilgrow replied on Fri, 2009/03/27 - 5:43pm
in response to: girish_ahankari
jkilgrow replied on Fri, 2009/03/27 - 5:52pm
in response to: dzb
jkilgrow replied on Fri, 2009/03/27 - 5:56pm
in response to: pwwallace
mr_bungalow replied on Thu, 2009/04/02 - 11:06am
WeiLing replied on Thu, 2009/04/02 - 1:41pm
in response to: mr_bungalow