July 26, 2010

JPA Entities to XML - Bidirectional Relationships

JAXB is your best choice when binding Java objects to XML.  But what happens when those Java objects turn out to be JPA entities?  For the most part it is business as usual, although there are a couple things to be aware of.  In this post we'll cover a MOXy extension that can be used to map a bidirectional relationship.

July 23, 2010

MOXy JAXB - Map Interfaces to XML

I recently came across a Twitter message (tweet) complaining that JAXB does not support binding Java interfaces to XML. Below I'll describe how this can be accomplished using MOXy in the upcoming EclipseLink 2.1.1 and 2.2 releases (try it now).

July 20, 2010

JAXB - The XML Binding Standard

Many people think of JAXB as an implementation (the reference implementation included in Java SE 6).  In reality JAXB is a Java Community Process (JCP) specification with multiple implementations (such as EclipseLink MOXy).  In this post I'll discuss the importance of JAXB the standard.

July 14, 2010

XPath Based Mapping

In this post we'll explore the XPath based mapping aspect of EclipseLink JAXB (MOXy).  XPath based mapping is what allows an existing object model to be mapped to an existing XML schema.  MOXy is the only XML binding solution I'm aware of with this ability and therefore the only true object-to-XML mapper (OXM).

July 13, 2010

CDATA, CDATA Run, Run Data Run

Recently the topic of JAXB's handling of CDATA has come up on a few separate Twitter messages (tweets). In this post I will describe how to handle CDATA using EclipseLink JAXB (MOXy).

July 12, 2010

XmlAdapter - JAXB's Secret Weapon

The XmlAdapter mechanism in JAXB ensures that there is no such thing as an unmappable class (with a little programmatic help). However there appears to be some confusion on how to use XmlAdapter, below is the general concept:
  1. Identify the unmappable class
  2. Create an equivalent class that is mappable
  3. Create an XmlAdapter to convert between unmappable and mappable objects
  4. Specify the XmlAdapter
Part of the problem may be due to the Javadocs on the XmlAdapter class. Below I'll flush out the example used there.