Chapter 5. Metadata

5.1. Persistence Metadata DTD
5.2. JDO, Package, and Extension Elements
5.3. Class Element
5.4. Field Element
5.5. Fetch Group Element
5.6. The Complete Document
5.7. Metadata Placement

JDO requires that you accompany each persistent class with JDO metadata. This metadata serves three primary purposes:

  1. To identify persistent classes.

  2. To override default JDO behavior.

  3. To provide the JDO implementation with information that it cannot glean from simply reflecting on the persistent class.

Metadata is specified as in the eXtensible Markup Language (XML). The Document Type Definition (DTD) for the persistence portion of metadata documents is given in the next section. JDO also standardizes relational mapping metadata and named query metadata, which we discuss in Chapter 15, Mapping Metadata and Section 11.10, “Named Queries” respectively. Do not worry about digesting the entire DTD immediately; we will fully cover each aspect of persistence metadata in turn.

5.1. Persistence Metadata DTD

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

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

<!ELEMENT class (extension*, field*, fetch-group*, extension*)>
<!ATTLIST class persistence-modifier (persistence-capable|persistence-aware) 
<!ATTLIST class identity-type (datastore|application|nondurable) #IMPLIED>
<!ATTLIST class objectid-class CDATA #IMPLIED>
<!ATTLIST class requires-extent (true|false) #IMPLIED>
<!ATTLIST class embedded-only (true|false) #IMPLIED>
<!ATTLIST class detachable (true|false) #IMPLIED>

<!ELEMENT field (extension*, (array|collection|map)?, extension*)>
<!ATTLIST field persistence-modifier (none|persistent|transactional) #IMPLIED>
<!ATTLIST field default-fetch-group (true|false) #IMPLIED>
<!ATTLIST field null-value (default|exception|none) #IMPLIED>
<!ATTLIST field dependent (true|false) #IMPLIED>
<!ATTLIST field embedded (true|false) #IMPLIED>
<!ATTLIST field primary-key (true|false) 'false'>
<!ATTLIST field fetch-depth CDATA #IMPLIED>

<!ELEMENT array (extension*)>
<!ATTLIST array embedded-element (true|false) #IMPLIED>
<!ATTLIST array dependent-element (true|false) #IMPLIED>

<!ELEMENT collection (extension*)>
<!ATTLIST collection element-type CDATA #IMPLIED>
<!ATTLIST collection embedded-element (true|false) #IMPLIED>
<!ATTLIST collection dependent-element (true|false) #IMPLIED>

<!ELEMENT map (extension*)>
<!ATTLIST map key-type CDATA #IMPLIED>
<!ATTLIST map embedded-key (true|false) #IMPLIED>
<!ATTLIST map dependent-key (true|false) #IMPLIED>
<!ATTLIST map value-type CDATA #IMPLIED>
<!ATTLIST map embedded-value (true|false) #IMPLIED>
<!ATTLIST map dependent-value (true|false) #IMPLIED>

<!ELEMENT fetch-group (field)*>
<!ATTLIST fetch-group name CDATA #REQUIRED>

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


Skip navigation bar   Back to Top