DataNucleus supports persisting/retrieving objects to/from XML documents (using the datanucleus-xml plugin). It makes use of JAXB. If you wish to help out in this effort either by contributing or by sponsoring particular functionality please contact us via the DataNucleus Forum.
DataNucleus supports file-based XML storage currently. The following persistence properties will connect to a local file on your local machine datanucleus.ConnectionURL=xml:file:myfile.xml replacing "myfile.xml" with your filename, which can be absolute or relative So you create your PersistenceManagerFactory or EntityManagerFactory with these properties. Thereafter you have the full power of the JDO or JPA APIs at your disposal, for your XML datastore.
Access Platform allows you to query the objects in the datastore using the following
The following are known limitations of the current implementation
When persisting a Java object to an XML datastore clearly the user would like some control over the structure of the XML document. Here's an example using JDO XML MetaData
<jdo>
<package name="org.datanucleus.samples.models.company">
<class name="Person" detachable="true" schema="/myproduct/people" table="person">
<field name="personNum">
<extension vendor-name="datanucleus" key="XmlAttribute" value="true"/>
</field>
<field name="firstName" primary-key="true"/> <!-- PK since JAXB requires String -->
<field name="lastName"/>
<field name="bestFriend"/>
</class>
</package>
</jdo>Things to note :
<?xml version="1.0" encoding="UTF-8"?>
<myproduct>
<people>
<person personNum="1">
<firstName>Bugs</firstName>
<lastName>Bunny</lastName>
<bestFriend>My</bestFriend>
</person>
</people>
Here's the same example using JDO Annotations
@PersistenceCapable(schema="/myproduct/people", table="person")
public class Person
{
@XmlAttribute
private long personNum;
@PrimaryKey
private String firstName;
private String lastName;
private Person bestFiend;
@XmlElementWrapper(name="phone-numbers")
@XmlElement(name="phone-number")
@Element(types=String.class)
private Map phoneNumbers = new HashMap();
...Here's the same example using JPA Annotations (with DataNucleus @Extension/@Extensions annotations)
TODO Add this example
|