Chapter 7. Hibernate
You have seen the basic principles. They may seem simplistic, but it’s surprisingly difficult to be disciplined enough to follow them. One place where experienced programmers have continually broken these simple rules is in the area of persistence frameworks. Sometimes, persistence solutions like EJB CMP are too invasive, requiring extensive code changes to support. Other times, persistence frameworks do not allow for extension, so common legacy models like stored procedures cannot be supported. More often than not, though, they’re simply overbuilt.
As a kid, you probably heard the story of the three little pigs. In this story, there’s a pig that “did it right the first time” by building a house out of brick. I’d like to suggest a more likely alternative. Once upon a time, there were three pigs that wanted to build houses. Two were reasonable and pragmatic. The third was an anal-retentive jerk. The first two pigs checked out the lay of the land and available resources. They built simple but functional houses with readily available, simple building materials. At the same time, the third pig decided to build a hardened mansion out of the world’s hardest brick. He began to plan. The first two pigs completed their houses and happily moved in before their brother was half done with his new place.
The third pig was in over his head. He eventually ran out of money before he could finish and abandoned the project, leaving town in disgrace. When a wolf threatened, ...