XML

JAXB based implementation

We can implement XML binding via JAXB at runtime. See:

http://weblogs.java.net/blog/kohsuke/archive/2007/07/binding_3rd_par.html 

http://java.sun.com/javaee/5/docs/tutorial/doc/bnazy.html 

JAXB provides an easy interface to serialize/deserialize objects, but does not allow modifications.

Current State

Supported only by JDK 1.5. Requires JAXB-RI 2.1. The jars are in local.repository

Each object is persisted as child of the root element. If the root element does not exists, a "root" element is created. You can set extension "xpath" to define the root element.

Mapping is done by dynamic runtime binding using JAXB. Dynamic binding is supported only by the JAXB reference implementation.

Only one XML file is supported by PMF (Should support unlimited number of files). The ConnectionURL is like: xml:file:filename.

The ConnectionFactory implementation returns a org.w3c.Document instance. If the file does not exist, it is created.

1-1 is now supported using xml id ref.

Embedded elements is supported. 

Basic queries is supported.

Persistent properties is not supported.

Known Issues

Property "fieldname" has an XmlID annotation but its type is not String

JAXB Limitation. The primary key must be of String type.

A cycle is detected in the object graph.

JAXB Limitation. You must use XmlID and XmlIDREF annotations for 1-1 bidirectional relationships.

Testing

To run the tests:

  • use the Eclipse IDE.
  • Build the enhancer jar using ant or maven
  • In the run configuration of Eclipse add the below to the VM arguments:
-javaagent:D:\workspace-dn\enhancer\target\dist\datanucleus-enhancer-1.0-SNAPSHOT.jar
-Dorg.datanucleus.test.properties.1=datanucleus-xml.1.properties
  • Add the store.xml to the classpath.
  • Add the jax-ri to the classpath.

Testing in JDK6

 If you face this issue, add the jaxb-api-2.1.jar to the folder jre/lib/endorsed.

java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI

Testing with Maven2

  • run:  mvn test -P xml

Labels

 
(None)