Show TOC Start of Content Area

  Object documentation JDO Mapping Metadata DTD  Locate the document in its SAP Library structure

Definition

This document type definition is used to produce a mapping metadata XML document that relates the JDO object model and the database schema. The relation to the JDO object model is done using the class and field elements. The relation to the database schema is done using the column and foreign-key elements. Since the resulting graph is not a tree in most cases, it is not possible to describe this graph as an XML document without references or without duplicate elements. To obtain a simple XML document, elements describing the database schema may be duplicates – for example, a primary key column can be also a part of a foreign key, so the column exists multiple times in the XML document.

Use

The mapping metadata document type definition has the following structure:

This graphic is explained in the accompanying text

 

The use of each element is explained in detail as follows:

<?xml version="1.0" encoding="UTF-8"?>

 

<!--

The root element. Supports the description of multiple packages in a document.

The version attribute specifies the version of the mapping metadata. The default version is 1.0.

-->

<!ELEMENT map (package)+>

<!ATTLIST map version CDATA #FIXED "1.0">

 

<!--

This element includes all classes in a particular package. The fully qualified package name is required in the name attribute.

Used in: map

-->

<!ELEMENT package (class)+>

<!ATTLIST package name CDATA #REQUIRED>

 

<!--

This element includes all non-relationship and relationship fields in a class. The class name is required in the name attribute. It is relative to the enclosing package. If the class is a persistence capable root class, then a discriminator element is included as a first element

Used in: package

-->

<!ELEMENT class (discriminator?,(field|relationship-field)*)>

<!ATTLIST class name CDATA #REQUIRED>

 

<!--

A field element is required for each persistent non-relationship field. The field name as defined in the class is required in the name attribute. The field element includes the columns to which a field is mapped. If the virtual attribute is set to true, you can add data to a field that is not declared in this class but is inherited. The default value of this attribute is false.

Used in: class

-->

<!ELEMENT field (column)+>

<!ATTLIST field name CDATA #REQUIRED>

<!ATTLIST field virtual (true|false) 'false'>

 

<!--

A relationship field element is required for each persistent relationship field.

The field name as defined in the class is required in the name attribute.

The relationship-field element contains all foreign keys and generic persistent references for this relationship.

The multiplicity attribute is one or many, depending on the relationship type. The default is one.

The join-table attribute must be set to true if a join table is used. The default is false.

If the update attribute is set to false, the value of this relationship field is not used for changing the database. This attribute is only relevant for many-to-many and one-to-one bidirectional relationships. In this case, one of the sides must be declared as non-updatable. The default value for this attribute is true.

Used in: class

-->

<!ELEMENT relationship-field

 (count?, (foreign-key|(discriminator,reference,serialized-data?)|(foreign-key,(foreign-key|(discriminator,reference,serialized-data?)))))>

<!ATTLIST relationship-field name CDATA #REQUIRED>

<!ATTLIST relationship-field multiplicity (one|many) 'one'>

<!ATTLIST relationship-field join-table (true|false) 'false'>

<!ATTLIST relationship-field update (true|false) 'true'>

 

<!--

This element contains the column for the number of duplicates.

Used in: relationship-field

-->

<!ELEMENT count (column)>

 

<!--

This element contains the discriminator column where the type of the instance is stored. The value of this element is the class name.

Used in: relationship-field

-->

<!ELEMENT discriminator (column)>

 

<!--

This element contains the reference column where the object identifier (OID) of a referenced persistent capable instance is stored. This may be the string representation of the OID.

Used in: relationship-field

-->

<!ELEMENT reference (column)>

 

<!--

This element contains the serialized-data column where a referenced non-persistence-capable instance is stored as a BLOB (Dictionary built-in type - binary). Furthermore, a collection type value with non-persistence-capable element type is stored in a serialized data column.

Used in: relationship-field

-->

<!ELEMENT serialized-data (column)>

 

<!--

This element describes a database column. The name of the column is required in the name attribute and the table name is required in the table attribute.

Used in: field, count, discriminator, reference, serialized-data

-->

<!ELEMENT column (jdbc-type)?>

<!ATTLIST column name CDATA #REQUIRED>

<!ATTLIST column table CDATA #REQUIRED>

 

<!--

This element describes the JDBC type of a database column. The type is specified by the attribute’s name, length and decimals. The jdbc-type element is optional and must only be used if there is no catalog information available. The attributes is-primary-key and is-not-null provide further information on the database column.

Used in: column

-->

<!ELEMENT jdbc-type EMPTY>

<!ATTLIST jdbc-type name CDATA #REQUIRED>

<!ATTLIST jdbc-type length CDATA #IMPLIED>

<!ATTLIST jdbc-type decimals CDATA #IMPLIED>

<!ATTLIST jdbc-type is-not-null (true|false) 'false'>

<!ATTLIST jdbc-type is-primary-key (true|false) 'false'>

 

<!--

This element describes a foreign key in the database. The name of the foreign key is required in the name attribute. The foreign-key-table attribute and the primary-key-table attribute specify the foreign key and primary key tables in the database. The foreign-key element contains all corresponding columns in the foreign key and primary key tables as column-pair elements.

Used in: relationship-field

-->

<!ELEMENT foreign-key (column-pair)+>

<!ATTLIST foreign-key name CDATA #REQUIRED>

<!ATTLIST foreign-key foreign-key-table CDATA #REQUIRED>

<!ATTLIST foreign-key primary-key-table CDATA #REQUIRED>

 

<!--

This element describes a pair of corresponding foreign key and primary key columns. The names of these columns are required in the foreign-key-column attribute and the primary-key-column attribute respectively. The foreign and primary key columns belong to the foreign key and primary tables defined in the foreign-key element.

Used in: foreign-key

-->

<!ELEMENT column-pair EMPTY>

<!ATTLIST column-pair foreign-key-column CDATA #REQUIRED>

<!ATTLIST column-pair primary-key-column CDATA #REQUIRED>

 

See also:

 

Mapping Persistent Classes to Database Tables

 

End of Content Area