15.2. Mapping Metadata DTD
Prev | Chapter 15. Mapping Metadata | Next

## 15.2. Mapping Metadata DTD

Below we present the Document Type Definition for `.orm` files. Other than the root `orm` element, the same elements and attributes apply when integrating mapping metadata into `.jdo` files. When using integrated mapping, simply add the mapping attributes and elements below to your existing class and field metadata.

    <!ELEMENT orm (extension*, package+, extension*)>

    <!ELEMENT package (extension*, (class|sequence)+, extension*)>
    <!ATTLIST package name CDATA ''>

    <!ELEMENT sequence (extension*)>
    <!ATTLIST sequence name CDATA #REQUIRED>
    <!ATTLIST sequence strategy (nontransactional|transactional|contiguous) #IMPLIED>
    <!ATTLIST sequence datastore-sequence CDATA #IMPLIED>
    <!ATTLIST sequence factory-class CDATA #IMPLIED>

    <!ELEMENT class (extension*, datastore-identity?, inheritance?, version?, join*,  field*, extension*)>
    <!ATTLIST class name CDATA #REQUIRED>
    <!ATTLIST class table CDATA #IMPLIED>

    <!ELEMENT datastore-identity (extension*, column*, extension*)>
    <!ATTLIST datastore-identity strategy CDATA 'native'>
    <!ATTLIST datastore-identity sequence CDATA #IMPLIED>
    <!ATTLIST datastore-identity column CDATA #IMPLIED>

    <!ELEMENT inheritance (extension*, join?, discriminator?, extension*)>
    <!ATTLIST inheritance strategy CDATA #IMPLIED>

    <!ELEMENT discriminator (extension*, column*, index?, extension*)>
    <!ATTLIST discriminator strategy CDATA #IMPLIED>
    <!ATTLIST discriminator column CDATA #IMPLIED>
    <!ATTLIST discriminator indexed (true|false|unique) #IMPLIED>
    <!ATTLIST discriminator value CDATA #IMPLIED>

    <!ELEMENT version (extension*, column*, index?, extension*)>
    <!ATTLIST version strategy CDATA #IMPLIED>
    <!ATTLIST version column CDATA #IMPLIED>
    <!ATTLIST version indexed (true|false|unique) #IMPLIED>

    <!ELEMENT join (extension*, column*, foreign-key?, index?, unique?, extension*)>
    <!ATTLIST join outer (true|false) 'false'>
    <!ATTLIST join table CDATA #IMPLIED>
    <!ATTLIST join column CDATA #IMPLIED>
    <!ATTLIST join delete-action (restrict|cascade|null|default|none) #IMPLIED>
    <!ATTLIST join indexed (true|false|unique) #IMPLIED>
    <!ATTLIST join unique (true|false) #IMPLIED>

    <!ELEMENT column (extension*)>
    <!ATTLIST column name CDATA #IMPLIED>
    <!ATTLIST column jdbc-type CDATA #IMPLIED>
    <!ATTLIST column sql-type CDATA #IMPLIED>
    <!ATTLIST column length CDATA #IMPLIED>
    <!ATTLIST column scale CDATA #IMPLIED>
    <!ATTLIST column allows-null (true|false) #IMPLIED>
    <!ATTLIST column target CDATA #IMPLIED>
    <!ATTLIST column target-field CDATA #IMPLIED>
    <!ATTLIST column default-value CDATA #IMPLIED>

    <!ELEMENT field (extension*, join?, embedded?, element?, key?, value?, order?,
        column*, foreign-key?, index?, unique?, extension*)>
    <!ATTLIST field name CDATA #REQUIRED>
    <!ATTLIST field value-strategy CDATA #IMPLIED>
    <!ATTLIST field sequence CDATA #IMPLIED>
    <!ATTLIST field serialized (true|false) #IMPLIED>
    <!ATTLIST field table CDATA #IMPLIED>
    <!ATTLIST field column CDATA #IMPLIED>
    <!ATTLIST field delete-action (restrict|cascade|null|default|none) #IMPLIED>
    <!ATTLIST field indexed (true|false|unique) #IMPLIED>
    <!ATTLIST field unique (true|false) #IMPLIED>
    <!ATTLIST field mapped-by CDATA #IMPLIED>

    <!ELEMENT embedded (extension*, field*, extension*)>
    <!ATTLIST embedded null-indicator-column CDATA #IMPLIED>

    <!ELEMENT element (extension*, embedded?, column*, foreign-key?, index?, unique?, extension*)>
    <!ATTLIST element serialized (true|false) #IMPLIED>
    <!ATTLIST element table CDATA #IMPLIED>
    <!ATTLIST element column CDATA #IMPLIED>
    <!ATTLIST element delete-action (restrict|cascade|null|default|none) #IMPLIED>
    <!ATTLIST element indexed (true|false|unique) #IMPLIED>
    <!ATTLIST element unique (true|false) #IMPLIED>

    <!ELEMENT key (extension*, embedded?, column*, foreign-key?, index?, unique?, extension*)>
    <!ATTLIST key mapped-by CDATA #IMPLIED>
    <!ATTLIST key serialized (true|false) #IMPLIED>
    <!ATTLIST key table CDATA #IMPLIED>
    <!ATTLIST key column CDATA #IMPLIED>
    <!ATTLIST key delete-action (restrict|cascade|null|default|none) #IMPLIED>
    <!ATTLIST key indexed (true|false|unique) #IMPLIED>
    <!ATTLIST key unique (true|false) #IMPLIED>

    <!ELEMENT value (extension*, embedded?, column*, foreign-key?, index?, unique?, extension*)>
    <!ATTLIST value serialized (true|false) #IMPLIED>
    <!ATTLIST value table CDATA #IMPLIED>
    <!ATTLIST value column CDATA #IMPLIED>
    <!ATTLIST value delete-action (restrict|cascade|null|default|none) #IMPLIED>
    <!ATTLIST value indexed (true|false|unique) #IMPLIED>
    <!ATTLIST value unique (true|false) #IMPLIED>

    <!ELEMENT order (extension*, column*, index?, extension*)>
    <!ATTLIST order column CDATA #IMPLIED>
    <!ATTLIST order indexed (true|false|unique) #IMPLIED>

    <!ELEMENT index (extension*)>
    <!ATTLIST index name CDATA #IMPLIED>
    <!ATTLIST index table CDATA #IMPLIED>
    <!ATTLIST index unique (true|false) 'false'>

    <!ELEMENT foreign-key (extension*)>
    <!ATTLIST foreign-key name CDATA #IMPLIED>
    <!ATTLIST foreign-key table CDATA #IMPLIED>
    <!ATTLIST foreign-key delete-action (restrict|cascade|null|default) 'restrict'>
    <!ATTLIST foreign-key update-action (restrict|cascade|null|default) 'restrict'>
    <!ATTLIST foreign-key deferred (true|false) #IMPLIED>

    <!ELEMENT unique (extension*)>
    <!ATTLIST unique name CDATA #IMPLIED>
    <!ATTLIST unique table CDATA #IMPLIED>
    <!ATTLIST unique deferred (true|false) 'false'>

    <!ELEMENT extension ANY>
    <!ATTLIST extension vendor-name CDATA #REQUIRED>
    <!ATTLIST extension key CDATA #IMPLIED>
    <!ATTLIST extension value CDATA #IMPLIED>

Mapping metadata's basic structure is virtually identical to that of persistence metadata, as defined in Chapter 5, Metadata. The root `orm` element contains `package` elements, which contain `class` elements, which contain `field`s. The content of each mapping element, however, is very different than the content of its persistence metadata equivalent. The following sections discuss this content in detail.

Throughout this chapter, we will draw on the object model introduced in Chapter 5, Metadata. We present that model again below. As we discuss various aspects of mapping metadata, we will zoom in on specific areas of the model and show how we map the object layer to the relational layer.

Prev | Up | Next
Chapter 15. Mapping Metadata | Home | 15.3. Sequences