6.2. Metadata Factory
Prev | Chapter 6. Metadata | Next

## 6.2. Metadata Factory

The `kodo.MetaDataFactory` configuration property controls metadata loading and storing. This property takes a plugin string (see Section 2.5, “Plugin Configuration”) describing a concrete `kodo.meta.MetaDataFactory` implementation. A metadata factory can load mapping information as well as persistence metadata, or it can leave mapping information to a separate mapping factory (see Section 7.5, “Mapping Factory”). Kodo recognizes the following built-in metadata factories:

- `jpa`: Standard JPA metadata. This is an alias for the `kodo.persistence.PersistenceMetaDataFactory`.

- `jdo`: Standard JDO metadata. This is an alias for the `kodo.jdo.JDOMetaDataFactory`, which has the following configurable property:

  - `ScanTopDown`: This boolean property controls whether Kodo looks for metadata files top-down in the package tree. Kodo defaults to bottom-up scanning, meaning that when scanning for metadata for class `C`, Kodo looks first for `C.jdo`, then `package.jdo` in `C`'s package, then `package.jdo` in the parent package, and so forth to the package root.

- `kodo3`: Kodo 3.x metadata compatibility. This compatibility factory recognizes Kodo 3.x metadata extensions. It is an alias for the `kodo.jdo.DeprecatedJDOMetaDataFactory`.

The standard metadata factories all accept the following properties for locating persistent classes. Each property represents a different mechanism for locating persistent types; you can choose the mechanism or combination of mechanisms that are most convenient. See Section 5.1, “Persistent Class List” for a discussion of when it is necessary to list your persistent classes.

- `Types`: A semicolon-separated list of fully-qualified persistent class names.

- `Resources`: A semicolon-separated list of resource paths to metadata files or jar archives. Each jar archive will be scanned for annotated JPA entities or JDO metadata files based on your metadata factory.

- `URLs`: A semicolon-separated list of URLs of metadata files or jar archives. Each jar archive will be scanned for annotated JPA entities or JDO metadata files based on your metadata factory.

- `ClasspathScan`: A semicolon-separated list of directories or jar archives listed in your classpath. Each directory and jar archive will be scanned for annotated JPA entities or JDO metadata files based on your metadata factory.

Example 6.2. Setting a Standard Metadata Factory

JPA:

    <property name="kodo.MetaDataFactory" value="jpa"/>

JDO:

    kodo.MetaDataFactory: jdo(Resources=com/aaa/package.jdo;com/bbb/package.jdo,\
        ClasspathScan=build)

Example 6.3. Setting a Custom Metadata Factory

JPA XML format:

    <property name="kodo.MetaDataFactory" value="com.xyz.CustomMetaDataFactory"/>

JDO properties format:

    kodo.MetaDataFactory: com.xyz.CustomMetaDataFactory

Prev | Up | Next
Chapter 6. Metadata | Home | 6.3. Additional JPA Metadata