JEST response is either XML or JSON.
XML Representation
JEST represents persistent Java object graph in a schema-compliant XML. The schema is metamodel-driven and hence invariant to particular domain model.
The schema jest-instance.xsd is as follows:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified"
version="1.0">
<xsd:annotation>
<xsd:documentation><![CDATA[
Describes closure of managed persistence instance.
Each instance is described by all its loaded persistent attribute.
The related instances are resolved within the document root.
Document root represents zero or more instances.
The file must be named "jest-instance.xsd".
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:element name="instances">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="uri" minOccurs="1" maxOccurs="1" type="xsd:anyURI"/>
<xsd:element name="description" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="instance" minOccurs="0" maxOccurs="unbounded" type="instance-type" />
</xsd:sequence>
<xsd:attribute name="version" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:complexType name="instance-type">
<xsd:sequence>
<xsd:element name="id" type="basic-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="version" type="basic-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="basic" type="basic-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="enum" type="basic-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="embedded" type="instance-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="lob" type="lob-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="one-to-one" type="singular-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="many-to-one" type="singular-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="element-collection" type="collection-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="one-to-many" type="collection-attr-type" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="many-to-many" type="map-attr-type" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="required" />
</xsd:complexType>
<xsd:complexType name="ref-type">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="id" type="xsd:IDREF" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="ref-null">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="basic-attr-type">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" use="required" />
<xsd:attribute name="null" type="xsd:boolean" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="lob-attr-type">
<xsd:simpleContent>
<xsd:extension base="xsd:hexBinary">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" use="required" />
<xsd:attribute name="null" type="xsd:boolean" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="singular-attr-type">
<xsd:choice>
<xsd:element name="null" type="ref-null" />
<xsd:element name="ref" type="ref-type" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="collection-attr-type">
<xsd:sequence>
<xsd:element name="member" type="member-type" minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" use="required" />
<xsd:attribute name="member-type" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="map-attr-type">
<xsd:sequence>
<xsd:element name="entry" type="entry-type" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" use="required" />
<xsd:attribute name="key-type" type="xsd:string" use="required" />
<xsd:attribute name="value-type" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="basic-value-type">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="null" type="xsd:boolean" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="member-type">
<xsd:choice>
<xsd:element name="basic" type="basic-value-type" />
<xsd:element name="null" type="ref-null" />
<xsd:element name="ref" type="ref-type" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="entry-type">
<xsd:sequence>
<xsd:element name="key" type="member-type" minOccurs="1" maxOccurs="1" />
<xsd:element name="value" type="member-type" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Example of a serialized object graph
The example shows a Person (primary key p1) who is her own partner.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<instances>
<instance id="Person-p1">
<basic name="id" type="String">p1</basic>
<basic name="dob" type="Date">Fri Sep 08 00:00:00 CDT 1989</basic>
<basic name="firstName" type="String">Mary</basic>
<basic name="gender" type="Gender">Female</basic>
<basic name="lastName" type="String">Smith</basic>
<singular name="address" type="Address">
<instance id="Address-101">
<basic name="id" type="long">101</basic>
<basic name="country" type="String">C1</basic>
<basic name="state" type="String">State1</basic>
<basic name="street" type="String">Street1</basic>
<basic name="zip" type="int">10001</basic>
</instance>
</singular>
<singular name="partner" type="Person">
<ref id="Person-p1"/>
</singular>
</instance>
</instances>
JSON Representation
String-based representation of persistent Java object graphs in either XML or more succinct JSON form has to address the critical issue of circular reference, because persistent object graphs
often contains circular reference. JSON, at this point of writing, does not address circular reference. Hence JEST introduces special semantics within JSON format to refer to
instances in a serialized graph. However, the enhanced JSON can be parsed by standard JSON parsers.
Enhanced JSON representation in JEST introduces two special fields named $id and $ref to address circular reference. Each JSON object carries a $id field whose value is the persistent identity of the corresponding entity. When JSON serialization encounters a circular reference a