Skip to content
Alexey Valikov edited this page Aug 31, 2017 · 1 revision

JAXB

JAXB stands for Java Architecture for XML Binding. JAXB allows Java developers to map Java classes to XML representations. With JAXB you can easily marshall Java objects into XML and unmarshall XML into Java objects without the need to implement XML loading and saving routines in your program.

JAXB Reference Implementation comes with a schema compiler called XJC which consumes an XML schema and generates classes specific to the originating schema (schema-derived classes).

Hyperjaxb3 implements a plugin for JAXB RI schema compiler. This plugin enhances schema-derived classes so that they can be persisted with Java Persistence API.

Please check the purchase order tutorial to see JAXB, JPA and Hyperjaxb3 in action.

JAXB versions

JAXB 1

First generation of JAXB was specified in JSR 31. In JAXB 1, schema compiler generated a set of interfaces and a set of implementation classes which implemented these interfaces. Implementation classes also contained the marshalling, unmarshalling and validation code which made them very tangled. However logical binding of XML Schema constructs to Java constructs was quite similar to modern JAXB.

JAXB 1 RI was open source and could be extended with XJC add-ons (now XJC plugins). This inspired me to start the Hyperjaxb1 project with the idea to make schema-derived classes persistable with Hibernate. Hyperjaxb1 enhanced generated classes with Hibernate XDoclet annotations. Hyperjaxb1 was followed by Hyperjaxb2 which generated object-relational mappings in XML form (*.hbm.xml files).

JAXB 2

JAXB 2 started is a new generation of JAXB, based on annotations rather than on generated marshaller/unmarshaller code. This made schema-derived classes light and clear and JAXB usage easy and convenient. JAXB 2 is specified in JSR 222.

Due to severe incompatibilities between JAXB 2 and JAXB 1 reference implementations Hyperjaxb2 could not have been applied to JAXB 2.

JAXB 2.0

JAXB 2.0 specification was released in May 2006. For convenience and ease of use it was literaly a breakthrough for Java XML binding technologies. JAXB 2.0 API is included in JDK 1.6 distributions.

JAXB 2.1

JAXB 2.1 was made public in December 2006 as a maintenenance release for JAXB 2.0. JAXB 2.1 is considered as the current version of JAXB.

For technical reasons, you can't use JAXB 2.1 RI with older JAXB 2.0 API. However, JAXB 2.0 is a part of most JDK 1.6 distributions. Please see this document about JAXB 2.x on JDK 1.6.

Hyperjaxb3 is currently based on JAXB 2.1.

JAXB 2.2

JAXB 2.2 is not yet officially release (it's official status is currently "Maintenance Draft Review 2"). See this entry in Kohsuke's blog. There are not many differences between JAXB 2.2. and JAXB 2.1 so 2.2 is likely to be adopted easily.

JAXB resources

Clone this wiki locally