July 22nd, 2008 by
Lincoln Baxter III
Guide to Hibernate Annotations
Is there light at the end of the tunnel?
So I’m sure I’m not alone here, when I say that Hibernate can be frustrating, difficult to learn, and may even feel like to use it means to give up on some design principles that have been proven by many.
When you first begin, it feels like there are holes, inconsistencies, and problems that send you running home to the familiar behavior of plain SQL. But, I don’t think it’s time to give up on Hibernate yet.
Keep in mind that I am a relatively new Hibernate user, I consider myself somewhat experienced with software development, design patterns, principles, and best practices. If this sounds like you, read on…
I’m beginning a series of articles that will:
- document my journey with Hibernate
- be a guide for those of you who are still on your journey
- give me a way to remember why I’ve made the decisions that I’ve made; what was I thinking??
Please look forward to the following topics that will start out this series.
- Getting started quickly. (read it)
- Using a base class to map common fields. (read it)
- Criteria returning duplicate results in OneToMany relationships.
- The Abstract Dao.
- Keeping transactional behavior in a lazy world.
Also, feel free to comment on any of these topics, or request new topics. Remember to check the following resources; a lot of common problems can be solved by reading the hibernate FAQ.
For the purpose of these examples, please assume the following versions:
- Hibernate FAQ
- Hibernate Forums
- Java Persistence API
Over 400 pages just in the Core Reference Manual. And that’s only the beginning.
When a framework, not matter which, has a core reference manual over 400 pages you know it’s not a framework, it’s a problem. It’s a f*cking monster. Hibernate is like everything else in Java: bloated, cumbersome, galaxy-wide, mind-blowing complex… and what about the message errors? Simply unreadable.
Hibernate-like frameworks are NOT an asset. They are a horrible liability. Long live JDBC.
I using pure JPA for now.
Waiting for JDO to mature, if it ever.
Using Hibernate, is like using a huge hammer to fix an century old problem which should not be there in the first place.