Chapter 5. Hibernate and JBoss

Hibernate is not an official part of the J2EE specification. It is an Object/Relational Mapper that hides the complexity of marshalling and unmarshalling JavaBeans and ResultSets.

Hibernate is unique because it can run either in a J2EE container such as JBoss, or as a standalone service. JBoss 4.0.2 ships standard with Hibernate 3.0.2. This chapter focuses on integrating the two to streamline the persistence tier of your application. (For a more detailed look at installing and running Hibernate, see Hibernate: A Developer’s Notebook by James Elliott (O’Reilly).)

The Pros and Cons of ORMs

“Object/Relational mapping is the Vietnam of computer science...”—Ted Neward (author, Effective Enterprise Java (Addison-Wesley))

If you’ve read Neward’s work or heard him speak, you know that he is a smart, controversial, and very passionate technologist. We couldn’t think of a better sentiment to begin our chapter on ORMs.

His point is that the United States started in Vietnam by sending over a few advisors. Then we began to ship in limited numbers of ground troops. Before too long, things degenerated into a full-blown, messy, unpopular war where we were heavily committed and had a difficult time extricating ourselves.

Working with ORMs (in his mind) is really no different. You start out with simple objects that map neatly to single rows. Then you get brave and begin using composition (classes within classes). Hibernate is smart enough to handle that, ...

Get JBoss at Work: A Practical Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.