Chapter 6. Metadata

6.1. Generating Default JDO Metadata
6.2. JDO Metadata Extensions
6.2.1. Relation Extensions inverse-owner inverse-logical dependent element-dependent value-dependent key-dependent type element-type value-type key-type lrs Example
6.2.2. Schema Extensions jdbc-size jdbc-element-size jdbc-value-size jdbc-key-size jdbc-type jdbc-sql-type jdbc-indexed jdbc-element-indexed jdbc-value-indexed jdbc-key-indexed jdbc-ref-indexed jdbc-version-ind-indexed jdbc-class-ind-indexed jdbc-delete-action jdbc-element-delete-action jdbc-value-delete-action jdbc-key-delete-action jdbc-ref-delete-action Example
6.2.3. Object-Relational Mapping Extensions jdbc-class-map-name jdbc-version-ind-name jdbc-class-ind-name jdbc-field-map-name jdbc-field-mappings jdbc-ordered jdbc-container-meta jdbc-null-ind externalizer factory external-values jdbc-class-ind-value Example
6.2.4. Miscellaneous Extensions detachable detached-objectid-field detached-state-field fetch-group lock-group lock-groups data-cache data-cache-timeout sequence-assigned subclass-fetch-mode eager-fetch-mode jdbc-sequence-factory jdbc-sequence-name jdbc-auto-increment Example

The JDO Overview covers JDO metadata basics. This chapter discusses the tools Kodo JDO provides to aid in metadata creation, and metadata extensions that Kodo JDO recognizes.

6.1. Generating Default JDO Metadata

Kodo JDO includes a metadata tool for generating default JDO metadata for your persistent classes. The tool can only rely on reflection, so it cannot fill in information that is not available from the class definition itself, such as the element type of collections or the primary key fields of a class using application identity. It does, however, provide a good starting point from which to build up your metadata.

The metadata tool can be run via the included metadatatool shell/bat script, or through its Java class, kodo.meta.JDOMetaDataTool.

Example 6.1. Using the MetaDataTool

metadatatool -f mypackage/package.jdo mypackage/*.java

In addition to the standard configuration flags accepted by all Kodo JDO tools, the metadata tool recognizes the following command line flags:

  • -verbose/-v <true/t | false/f>: The metadata tool honors JDO's extensive system of defaults, so fields that are persistent by default will not be included in the generated XML document. The only exception to this rule is for collection and map fields: the tool adds these fields to the metadata and sets their element-type, key-type, and value-type attributes to Object as a reminder to you to provide this information. If you set this flag to true, however, the tool will generate <field> elements for every persistent field.

  • -file/-f <metadata file>: The name of the metadata file to generate. If this argument is not supplied, the tool will print the generated metadata to standard output.

Each additional argument to the tool should be the class name, .class file, or .java file of a class to generate metadata for. Each class must be compiled.