Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Simplify Java Object Persistence with Hibernate

The 'impedance mismatch' between relational databases' tabular orientation and object-oriented Java's hierarchical one is a perennial problem for which the Java world has several good solution offerings. The second in a three-part series, this article examines the ways that the Hibernate framework attempts to simplify the chore of connecting relational databases and the Java programming language.



Introducing Object Persistence
The task of persisting Java objects to a relational database is currently being facilitated by a number of different tools which allow developers to direct persistence engines in converting Java objects to database columns/records and back. This task involves serializing hierarchically-structured Java objects to a tabular-structured database and vice versa. Essential to this effort is the need to map Java objects to database columns and records in a manner optimized for speed and efficiency.

The Hibernate framework tackles the Java-object-to-database problem as elegantly as any framework currently available. Hibernate works by persisting and restoring plain old Java Objects (POJOs) using a very transparent and low-profile programming model.

An Overview of Hibernate
Hibernate is a Java framework that provides object/relational mapping mechanisms to define how Java objects are stored, updated, deleted, and retrieved. In addition, Hibernate offers query and retrieval services that can optimize development efforts within SQL and JDBC environments. Ultimately, Hibernate reduces the effort needed to convert between relational database result-sets and graphs of Java objects.

One of its unique features is that Hibernate does not require developers to implement proprietary interfaces or extend proprietary base classes in order for classes to be made persistent. Instead, Hibernate relies on Java reflection and runtime augmentation of classes using a powerful, high-performance, code-generation library for Java called CGLIB. CGLIB is used to extend Java classes and implement Java interfaces at runtime.

Comment and Contribute








