Hyperjaxb2

Hyperjaxb2

Primary goal of the Hyperjaxb development is to provide JAXB objects with a relational persistence layer. To achieve this goal, several add-ons have been developed, which combines Sun's reference implementation of JAXB with Hibernate (Java), a well-known object/relational mapping tool.

Overview

In one sentence, Hyperjaxb provides a solution for the prevalent task of XML persistence which essentially lies in the following three operations:

* importing or saving the document;
* exporting or loading the document;
* querying for documents or their parts.

To solve this task, Hyperjaxb combines two technogies: Java Architecture for XML Binding and Hibernate. JAXB converts between XML and objects; Hibernate is used to persist object in a relational database.

JAXB implements the conversion between XML and Java objects. To accomplish this, XML Schema (with some additional binding configuration) is processed by the binding compiler (XJC) which generates so-called schema-derived classes (their source code). These classes bear information required for the marshalling and unmarshalling of XML data. Together with the JAXB runtime, they allow parsing XML into content objects (instances of schema-derived classes).

Hibernate in its turn implements object-relational persistence. Provided the object-relational mapping configuration, Hibernate is capable of saving objects into the relational database, loading them back as well as processing queries. Moreover, Hibernate also provides a very handy schema export tool which can automatically generate the database schema based on the Hibernate mapping.

In order to for JAXB and Hibernate to be combined, Hibernate mapping for schema-derived classes must be generated out of the XML Schema (as well as the schema-derived classes themselves). For this purpose, Hyperjaxb includes an XJC add-on which analyzes classes and fields generated by JAXB and produces the appropriate mapping.

The overall usage of Hyperjaxb in a project (provided the schema) may be sketched out as follows:

* Build phase:
** Use binding compiler (XJC) together with Hyperjaxb add-on to generate the source code of schema-derived classes and Hibernate mapping.
** Compile the generated classes.
** Use Hibernate toolset to export the database schema.

* Runtime phase:
** Use JAXB runtime and schema-derived classes to convert between XML and content objects.
** Use Hibernate to save content objects into the database and load them back.
** Use HQL to formulate queries and process them with Hibernate. Again, use JAXB to marshall results as XML.

External links

* [https://hyperjaxb.dev.java.net/ Hyperjaxb (support for JAXB1.x/Hibernate 2.x)]
* [https://hyperjaxb2.dev.java.net/ Hyperjaxb2 (support for JAXB1.x/Hibernate 3.x)]
* [https://hyperjaxb3.dev.java.net/ Hyperjaxb3 (support for JAXB2.x/Hibernate 3.x/EJB3/JDO)]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”