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


Hibernate 3 Adds XML-Relational Persistence

Thanks to the XML persistence features in the recently released Hibernate 3, Java developers now have a framework that provides an efficient and consistent method for effortless OR and XML persistence.

ibernate has taken the IT world by surprise with its easy-to-use, high-performance, and sophisticated features for object-relational (OR) persistence. The most recent version of Hibernate (version 3, released on March 29) brings an important new feature to the product API: XML persistence. With Hibernate 3, Java application developers can conveniently persist XML documents into relational databases.

This new feature definitely should appeal to existing Hibernate developers because it follows the same persistence methods as POJOs (plain old Java objects), requiring a minimal learning curve. The convenience of XML persistence should appeal to new users as well. This article describes the Hibernate 3 persistence method.

Why XML Persistence Is Important
Most of the larger commercial databases support some form of native XML persistence. Since XML persistence is a relatively new mechanism—even for larger vendors, the standards in this field are still emerging. As a result, in order to integrate the ubiquitous relational persistence mechanisms with increasingly prevalent XML solutions, an architect must either resort to vendor-specific features or implement a custom XML persistence framework. Neither is a particularly attractive option. Vendor-specific features are unpopular because they can lead to vendor lock-in, and a custom framework implementation can be laborious and lengthy, resulting in code that is hard to maintain.

As is the case with OR persistence, Hibernate XML persistence is as a natural solution for this scenario. It is portable across all of the relational platforms that Hibernate supports (i.e., virtually all true relational platforms), allowing for the freedom to migrate objects and XML-based application and integration solutions without worrying about the underlying relational implementation.

Architectural Specifics
Hibernate is a nicely architected framework that seamlessly utilizes native environments without any special interventions or installations by the user. Switching from one database to another is usually a matter of changing a driver and configuring Hibernate (one-line configuration setting) to use one database dialect versus another.

Hibernate utilizes the dom4j framework for XML parsing and manipulation. To fully utilize Hibernate's XML features, you must get familiar with dom4j. Most likely, you will find dom4j easier to use than JAXP and JAXP-compliant XML parsers that are supplied through Java. It has a very flat learning curve and you can start using the Hibernate XML persistence features effectively with minimal dom4j knowledge.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date